summaryrefslogtreecommitdiffstats
path: root/door_lock/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'door_lock/cmd.c')
-rw-r--r--door_lock/cmd.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/door_lock/cmd.c b/door_lock/cmd.c
new file mode 100644
index 0000000..ccfbafb
--- /dev/null
+++ b/door_lock/cmd.c
@@ -0,0 +1,33 @@
+#include <stdint.h>
+#include <string.h>
+
+#include "cmd.h"
+
+#define XORLEN 32
+#define KEY "dM>}jdb,6gsnC$J^K 8(I5vyPemPs%;K"
+#define ULOCK_CMD "43iqr5$NB8SpN?Z/52{iVl>o|i!.'dsT"
+
+static char ulock_crypt_cmd[XORLEN];
+
+static inline void xor(const char *s, char *d, uint8_t n)
+{
+ int i;
+
+ for (i = 0; i < n && s[i]; i++)
+ d[i] = s[i] ^ KEY[i];
+}
+
+int is_ulock_cmd(const char *s)
+{
+ char buf[XORLEN + 1];
+
+ xor(s, buf, XORLEN);
+ buf[XORLEN] = 0;
+ return !strcmp(ULOCK_CMD, buf);
+}
+
+char * get_encrypted_ulock_cmd(void)
+{
+ xor(ULOCK_CMD, ulock_crypt_cmd, XORLEN);
+ return ulock_crypt_cmd;
+}