Explorar el Código

really define LTC_{DE,EN}CRYPT

Steffen Jaeckel hace 8 años
padre
commit
22822417c9

+ 5 - 0
src/headers/tomcrypt_cfg.h

@@ -64,6 +64,11 @@ LTC_EXPORT int   LTC_CALL XSTRCMP(const char *s1, const char *s2);
    #define ARGTYPE  0
 #endif
 
+#undef LTC_ENCRYPT
+#define LTC_ENCRYPT 0
+#undef LTC_DECRYPT
+#define LTC_DECRYPT 1
+
 /* Controls endianess and size of registers.  Leave uncommented to get platform neutral [slower] code
  *
  * Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes.

+ 2 - 2
src/headers/tomcrypt_cipher.h

@@ -875,8 +875,8 @@ int ctr_test(void);
 
 #ifdef LTC_LRW_MODE
 
-#define LRW_ENCRYPT 0
-#define LRW_DECRYPT 1
+#define LRW_ENCRYPT LTC_ENCRYPT
+#define LRW_DECRYPT LTC_DECRYPT
 
 int lrw_start(               int   cipher,
               const unsigned char *IV,

+ 6 - 6
src/headers/tomcrypt_mac.h

@@ -311,8 +311,8 @@ void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const
 
 #ifdef LTC_CCM_MODE
 
-#define CCM_ENCRYPT 0
-#define CCM_DECRYPT 1
+#define CCM_ENCRYPT LTC_ENCRYPT
+#define CCM_DECRYPT LTC_DECRYPT
 
 typedef struct {
    symmetric_key       K;
@@ -378,8 +378,8 @@ extern const unsigned char gcm_shift_table[];
 
 #ifdef LTC_GCM_MODE
 
-#define GCM_ENCRYPT 0
-#define GCM_DECRYPT 1
+#define GCM_ENCRYPT LTC_ENCRYPT
+#define GCM_DECRYPT LTC_DECRYPT
 
 #define LTC_GCM_MODE_IV    0
 #define LTC_GCM_MODE_AAD   1
@@ -542,8 +542,8 @@ typedef struct {
    int aadflg;
 } chacha20poly1305_state;
 
-#define CHCHA20POLY1305_ENCRYPT 0
-#define CHCHA20POLY1305_DECRYPT 1
+#define CHCHA20POLY1305_ENCRYPT LTC_ENCRYPT
+#define CHCHA20POLY1305_DECRYPT LTC_DECRYPT
 
 int chacha20poly1305_init(chacha20poly1305_state *st, const unsigned char *key, unsigned long keylen);
 int chacha20poly1305_setiv(chacha20poly1305_state *st, const unsigned char *iv, unsigned long ivlen);

+ 2 - 2
src/misc/crypt/crypt_constants.c

@@ -30,8 +30,8 @@ static const crypt_constant _crypt_constants[] = {
     _C_STRINGIFY(PK_PUBLIC),
     _C_STRINGIFY(PK_PRIVATE),
 
-    {"LTC_ENCRYPT", 0},      /* good for all other xxx_ENCRYPT prefixes */
-    {"LTC_DECRYPT", 1},      /* good for all other xxx_DECRYPT prefixes */
+    _C_STRINGIFY(LTC_ENCRYPT),
+    _C_STRINGIFY(LTC_DECRYPT),
 
     _C_STRINGIFY(PKA_RSA),
     _C_STRINGIFY(PKA_DSA),