]> git.stg.codes - stg.git/blobdiff - libs/crypto/include/stg/blowfish.h
Port to CMake, get rid of os_int.h.
[stg.git] / libs / crypto / include / stg / blowfish.h
diff --git a/libs/crypto/include/stg/blowfish.h b/libs/crypto/include/stg/blowfish.h
new file mode 100644 (file)
index 0000000..6a4e6f3
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Author     :  Paul Kocher
+ * E-mail     :  pck@netcom.com
+ * Date       :  1997
+ * Description:  C implementation of the Blowfish algorithm.
+ */
+
+#ifndef BLOWFISH_H
+#define BLOWFISH_H
+
+#define MAXKEYBYTES 56          /* 448 bits */
+
+#ifdef __cplusplus
+#include <cstddef> // size_t
+#include <cstdint>
+extern "C" {
+#else
+#include <stddef.h> // size_t
+#include <stdint.h>
+#endif
+
+typedef struct {
+  uint32_t P[16 + 2];
+  uint32_t S[4][256];
+} BLOWFISH_CTX;
+
+void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char * key, int keyLen);
+void Blowfish_Encrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr);
+void Blowfish_Decrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr);
+
+void InitContext(const char * key, size_t length, BLOWFISH_CTX * ctx);
+void DecryptBlock(void * d, const void * s, const BLOWFISH_CTX * ctx);
+void EncryptBlock(void * d, const void * s, const BLOWFISH_CTX * ctx);
+
+void DecryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx);
+void EncryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+