maxep преди 5 години
родител
ревизия
22b1a33ce6

+ 78 - 81
Sources/Argon2/argon2.c

@@ -23,7 +23,7 @@
 #include "encoding.h"
 #include "core.h"
 
-const char *argon2_type2string(argon2_type type, int uppercase) {
+const char *kp_argon2_type2string(argon2_type_t type, int uppercase) {
     switch (type) {
         case Argon2_d:
             return uppercase ? "Argon2d" : "argon2d";
@@ -36,7 +36,7 @@ const char *argon2_type2string(argon2_type type, int uppercase) {
     return NULL;
 }
 
-int argon2_ctx(argon2_context *context, argon2_type type) {
+int kp_argon2_ctx(argon2_context_t *context, argon2_type_t type) {
     /* 1. Validate all inputs */
     int result = validate_inputs(context);
     uint32_t memory_blocks, segment_length;
@@ -97,14 +97,14 @@ int argon2_ctx(argon2_context *context, argon2_type type) {
     return ARGON2_OK;
 }
 
-int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
+int kp_argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
                 const uint32_t parallelism, const void *pwd,
                 const size_t pwdlen, const void *salt, const size_t saltlen,
                 void *hash, const size_t hashlen, char *encoded,
-                const size_t encodedlen, argon2_type type,
+                const size_t encodedlen, argon2_type_t type,
                 const uint32_t version){
 
-    argon2_context context;
+    argon2_context_t context;
     int result;
     uint8_t *out;
 
@@ -148,7 +148,7 @@ int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
     context.flags = ARGON2_DEFAULT_FLAGS;
     context.version = version;
 
-    result = argon2_ctx(&context, type);
+    result = kp_argon2_ctx(&context, type);
 
     if (result != ARGON2_OK) {
         clear_internal_memory(out, hashlen);
@@ -176,67 +176,67 @@ int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
     return ARGON2_OK;
 }
 
-int argon2i_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
-                         const uint32_t parallelism, const void *pwd,
-                         const size_t pwdlen, const void *salt,
-                         const size_t saltlen, const size_t hashlen,
-                         char *encoded, const size_t encodedlen) {
+int kp_argon2i_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
+                            const uint32_t parallelism, const void *pwd,
+                            const size_t pwdlen, const void *salt,
+                            const size_t saltlen, const size_t hashlen,
+                            char *encoded, const size_t encodedlen) {
 
-    return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
-                       NULL, hashlen, encoded, encodedlen, Argon2_i,
-                       ARGON2_VERSION_NUMBER);
+    return kp_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
+                          NULL, hashlen, encoded, encodedlen, Argon2_i,
+                          ARGON2_VERSION_NUMBER);
 }
 
-int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
-                     const uint32_t parallelism, const void *pwd,
-                     const size_t pwdlen, const void *salt,
-                     const size_t saltlen, void *hash, const size_t hashlen) {
+int kp_argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
+                        const uint32_t parallelism, const void *pwd,
+                        const size_t pwdlen, const void *salt,
+                        const size_t saltlen, void *hash, const size_t hashlen) {
 
-    return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
-                       hash, hashlen, NULL, 0, Argon2_i, ARGON2_VERSION_NUMBER);
+    return kp_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
+                          hash, hashlen, NULL, 0, Argon2_i, ARGON2_VERSION_NUMBER);
 }
 
-int argon2d_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
-                         const uint32_t parallelism, const void *pwd,
-                         const size_t pwdlen, const void *salt,
-                         const size_t saltlen, const size_t hashlen,
-                         char *encoded, const size_t encodedlen) {
+int kp_argon2d_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
+                            const uint32_t parallelism, const void *pwd,
+                            const size_t pwdlen, const void *salt,
+                            const size_t saltlen, const size_t hashlen,
+                            char *encoded, const size_t encodedlen) {
 
-    return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
-                       NULL, hashlen, encoded, encodedlen, Argon2_d,
-                       ARGON2_VERSION_NUMBER);
+    return kp_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
+                          NULL, hashlen, encoded, encodedlen, Argon2_d,
+                          ARGON2_VERSION_NUMBER);
 }
 
-int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
-                     const uint32_t parallelism, const void *pwd,
-                     const size_t pwdlen, const void *salt,
-                     const size_t saltlen, void *hash, const size_t hashlen) {
+int kp_argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
+                        const uint32_t parallelism, const void *pwd,
+                        const size_t pwdlen, const void *salt,
+                        const size_t saltlen, void *hash, const size_t hashlen) {
 
-    return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
-                       hash, hashlen, NULL, 0, Argon2_d, ARGON2_VERSION_NUMBER);
+    return kp_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
+                          hash, hashlen, NULL, 0, Argon2_d, ARGON2_VERSION_NUMBER);
 }
 
-int argon2id_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
-                          const uint32_t parallelism, const void *pwd,
-                          const size_t pwdlen, const void *salt,
-                          const size_t saltlen, const size_t hashlen,
-                          char *encoded, const size_t encodedlen) {
+int kp_argon2id_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
+                             const uint32_t parallelism, const void *pwd,
+                             const size_t pwdlen, const void *salt,
+                             const size_t saltlen, const size_t hashlen,
+                             char *encoded, const size_t encodedlen) {
 
-    return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
-                       NULL, hashlen, encoded, encodedlen, Argon2_id,
-                       ARGON2_VERSION_NUMBER);
+    return kp_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
+                          NULL, hashlen, encoded, encodedlen, Argon2_id,
+                          ARGON2_VERSION_NUMBER);
 }
 
-int argon2id_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
-                      const uint32_t parallelism, const void *pwd,
-                      const size_t pwdlen, const void *salt,
-                      const size_t saltlen, void *hash, const size_t hashlen) {
-    return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
-                       hash, hashlen, NULL, 0, Argon2_id,
-                       ARGON2_VERSION_NUMBER);
+int kp_argon2id_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
+                         const uint32_t parallelism, const void *pwd,
+                         const size_t pwdlen, const void *salt,
+                         const size_t saltlen, void *hash, const size_t hashlen) {
+    return kp_argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
+                          hash, hashlen, NULL, 0, Argon2_id,
+                          ARGON2_VERSION_NUMBER);
 }
 
-static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
+static int kp_argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
     size_t i;
     uint8_t d = 0U;
 
@@ -246,10 +246,10 @@ static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
     return (int)((1 & ((d - 1) >> 8)) - 1);
 }
 
-int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
-                  argon2_type type) {
+int kp_argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
+                     argon2_type_t type) {
 
-    argon2_context ctx;
+    argon2_context_t ctx;
     uint8_t *desired_result = NULL;
 
     int ret = ARGON2_OK;
@@ -299,7 +299,7 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
         goto fail;
     }
 
-    ret = argon2_verify_ctx(&ctx, (char *)desired_result, type);
+    ret = kp_argon2_verify_ctx(&ctx, (char *)desired_result, type);
     if (ret != ARGON2_OK) {
         goto fail;
     }
@@ -312,57 +312,54 @@ fail:
     return ret;
 }
 
-int argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
-
-    return argon2_verify(encoded, pwd, pwdlen, Argon2_i);
+int kp_argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
+    return kp_argon2_verify(encoded, pwd, pwdlen, Argon2_i);
 }
 
-int argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
-
-    return argon2_verify(encoded, pwd, pwdlen, Argon2_d);
+int kp_argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
+    return kp_argon2_verify(encoded, pwd, pwdlen, Argon2_d);
 }
 
-int argon2id_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
-
-    return argon2_verify(encoded, pwd, pwdlen, Argon2_id);
+int kp_argon2id_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
+    return kp_argon2_verify(encoded, pwd, pwdlen, Argon2_id);
 }
 
-int argon2d_ctx(argon2_context *context) {
-    return argon2_ctx(context, Argon2_d);
+int kp_argon2d_ctx(argon2_context_t *context) {
+    return kp_argon2_ctx(context, Argon2_d);
 }
 
-int argon2i_ctx(argon2_context *context) {
-    return argon2_ctx(context, Argon2_i);
+int kp_argon2i_ctx(argon2_context_t *context) {
+    return kp_argon2_ctx(context, Argon2_i);
 }
 
-int argon2id_ctx(argon2_context *context) {
-    return argon2_ctx(context, Argon2_id);
+int kp_argon2id_ctx(argon2_context_t *context) {
+    return kp_argon2_ctx(context, Argon2_id);
 }
 
-int argon2_verify_ctx(argon2_context *context, const char *hash,
-                      argon2_type type) {
-    int ret = argon2_ctx(context, type);
+int kp_argon2_verify_ctx(argon2_context_t *context, const char *hash,
+                      argon2_type_t type) {
+    int ret = kp_argon2_ctx(context, type);
     if (ret != ARGON2_OK) {
         return ret;
     }
 
-    if (argon2_compare((uint8_t *)hash, context->out, context->outlen)) {
+    if (kp_argon2_compare((uint8_t *)hash, context->out, context->outlen)) {
         return ARGON2_VERIFY_MISMATCH;
     }
 
     return ARGON2_OK;
 }
 
-int argon2d_verify_ctx(argon2_context *context, const char *hash) {
-    return argon2_verify_ctx(context, hash, Argon2_d);
+int kp_argon2d_verify_ctx(argon2_context_t *context, const char *hash) {
+    return kp_argon2_verify_ctx(context, hash, Argon2_d);
 }
 
-int argon2i_verify_ctx(argon2_context *context, const char *hash) {
-    return argon2_verify_ctx(context, hash, Argon2_i);
+int kp_argon2i_verify_ctx(argon2_context_t *context, const char *hash) {
+    return kp_argon2_verify_ctx(context, hash, Argon2_i);
 }
 
-int argon2id_verify_ctx(argon2_context *context, const char *hash) {
-    return argon2_verify_ctx(context, hash, Argon2_id);
+int kp_argon2id_verify_ctx(argon2_context_t *context, const char *hash) {
+    return kp_argon2_verify_ctx(context, hash, Argon2_id);
 }
 
 const char *argon2_error_message(int error_code) {
@@ -445,8 +442,8 @@ const char *argon2_error_message(int error_code) {
 }
 
 size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism,
-                         uint32_t saltlen, uint32_t hashlen, argon2_type type) {
-  return strlen("$$v=$m=,t=,p=$$") + strlen(argon2_type2string(type, 0)) +
+                         uint32_t saltlen, uint32_t hashlen, argon2_type_t type) {
+  return strlen("$$v=$m=,t=,p=$$") + strlen(kp_argon2_type2string(type, 0)) +
          numlen(t_cost) + numlen(m_cost) + numlen(parallelism) +
          b64len(saltlen) + b64len(hashlen) + numlen(ARGON2_VERSION_NUMBER) + 1;
 }

+ 24 - 24
Sources/Argon2/blake2b.c

@@ -70,7 +70,7 @@ static BLAKE2_INLINE void blake2b_init0(blake2b_state *S) {
     memcpy(S->h, blake2b_IV, sizeof(S->h));
 }
 
-int blake2b_init_param(blake2b_state *S, const blake2b_param *P) {
+int kp_blake2b_init_param(blake2b_state *S, const blake2b_param *P) {
     const unsigned char *p = (const unsigned char *)P;
     unsigned int i;
 
@@ -88,7 +88,7 @@ int blake2b_init_param(blake2b_state *S, const blake2b_param *P) {
 }
 
 /* Sequential blake2b initialization */
-int blake2b_init(blake2b_state *S, size_t outlen) {
+int kp_blake2b_init(blake2b_state *S, size_t outlen) {
     blake2b_param P;
 
     if (S == NULL) {
@@ -113,10 +113,10 @@ int blake2b_init(blake2b_state *S, size_t outlen) {
     memset(P.salt, 0, sizeof(P.salt));
     memset(P.personal, 0, sizeof(P.personal));
 
-    return blake2b_init_param(S, &P);
+    return kp_blake2b_init_param(S, &P);
 }
 
-int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
+int kp_blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
                      size_t keylen) {
     blake2b_param P;
 
@@ -147,7 +147,7 @@ int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
     memset(P.salt, 0, sizeof(P.salt));
     memset(P.personal, 0, sizeof(P.personal));
 
-    if (blake2b_init_param(S, &P) < 0) {
+    if (kp_blake2b_init_param(S, &P) < 0) {
         blake2b_invalidate_state(S);
         return -1;
     }
@@ -156,7 +156,7 @@ int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
         uint8_t block[BLAKE2B_BLOCKBYTES];
         memset(block, 0, BLAKE2B_BLOCKBYTES);
         memcpy(block, key, keylen);
-        blake2b_update(S, block, BLAKE2B_BLOCKBYTES);
+        kp_blake2b_update(S, block, BLAKE2B_BLOCKBYTES);
         /* Burn the key from stack */
         clear_internal_memory(block, BLAKE2B_BLOCKBYTES);
     }
@@ -221,7 +221,7 @@ static void blake2b_compress(blake2b_state *S, const uint8_t *block) {
 #undef ROUND
 }
 
-int blake2b_update(blake2b_state *S, const void *in, size_t inlen) {
+int kp_blake2b_update(blake2b_state *S, const void *in, size_t inlen) {
     const uint8_t *pin = (const uint8_t *)in;
 
     if (inlen == 0) {
@@ -261,7 +261,7 @@ int blake2b_update(blake2b_state *S, const void *in, size_t inlen) {
     return 0;
 }
 
-int blake2b_final(blake2b_state *S, void *out, size_t outlen) {
+int kp_blake2b_final(blake2b_state *S, void *out, size_t outlen) {
     uint8_t buffer[BLAKE2B_OUTBYTES] = {0};
     unsigned int i;
 
@@ -291,7 +291,7 @@ int blake2b_final(blake2b_state *S, void *out, size_t outlen) {
     return 0;
 }
 
-int blake2b(void *out, size_t outlen, const void *in, size_t inlen,
+int kp_blake2b(void *out, size_t outlen, const void *in, size_t inlen,
             const void *key, size_t keylen) {
     blake2b_state S;
     int ret = -1;
@@ -310,19 +310,19 @@ int blake2b(void *out, size_t outlen, const void *in, size_t inlen,
     }
 
     if (keylen > 0) {
-        if (blake2b_init_key(&S, outlen, key, keylen) < 0) {
+        if (kp_blake2b_init_key(&S, outlen, key, keylen) < 0) {
             goto fail;
         }
     } else {
-        if (blake2b_init(&S, outlen) < 0) {
+        if (kp_blake2b_init(&S, outlen) < 0) {
             goto fail;
         }
     }
 
-    if (blake2b_update(&S, in, inlen) < 0) {
+    if (kp_blake2b_update(&S, in, inlen) < 0) {
         goto fail;
     }
-    ret = blake2b_final(&S, out, outlen);
+    ret = kp_blake2b_final(&S, out, outlen);
 
 fail:
     clear_internal_memory(&S, sizeof(S));
@@ -330,7 +330,7 @@ fail:
 }
 
 /* Argon2 Team - Begin Code */
-int blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) {
+int kp_blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) {
     uint8_t *out = (uint8_t *)pout;
     blake2b_state blake_state;
     uint8_t outlen_bytes[sizeof(uint32_t)] = {0};
@@ -352,25 +352,25 @@ int blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) {
     } while ((void)0, 0)
 
     if (outlen <= BLAKE2B_OUTBYTES) {
-        TRY(blake2b_init(&blake_state, outlen));
-        TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes)));
-        TRY(blake2b_update(&blake_state, in, inlen));
-        TRY(blake2b_final(&blake_state, out, outlen));
+        TRY(kp_blake2b_init(&blake_state, outlen));
+        TRY(kp_blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes)));
+        TRY(kp_blake2b_update(&blake_state, in, inlen));
+        TRY(kp_blake2b_final(&blake_state, out, outlen));
     } else {
         uint32_t toproduce;
         uint8_t out_buffer[BLAKE2B_OUTBYTES];
         uint8_t in_buffer[BLAKE2B_OUTBYTES];
-        TRY(blake2b_init(&blake_state, BLAKE2B_OUTBYTES));
-        TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes)));
-        TRY(blake2b_update(&blake_state, in, inlen));
-        TRY(blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES));
+        TRY(kp_blake2b_init(&blake_state, BLAKE2B_OUTBYTES));
+        TRY(kp_blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes)));
+        TRY(kp_blake2b_update(&blake_state, in, inlen));
+        TRY(kp_blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES));
         memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2);
         out += BLAKE2B_OUTBYTES / 2;
         toproduce = (uint32_t)outlen - BLAKE2B_OUTBYTES / 2;
 
         while (toproduce > BLAKE2B_OUTBYTES) {
             memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES);
-            TRY(blake2b(out_buffer, BLAKE2B_OUTBYTES, in_buffer,
+            TRY(kp_blake2b(out_buffer, BLAKE2B_OUTBYTES, in_buffer,
                         BLAKE2B_OUTBYTES, NULL, 0));
             memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2);
             out += BLAKE2B_OUTBYTES / 2;
@@ -378,7 +378,7 @@ int blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) {
         }
 
         memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES);
-        TRY(blake2b(out_buffer, toproduce, in_buffer, BLAKE2B_OUTBYTES, NULL,
+        TRY(kp_blake2b(out_buffer, toproduce, in_buffer, BLAKE2B_OUTBYTES, NULL,
                     0));
         memcpy(out, out_buffer, toproduce);
     }

+ 30 - 30
Sources/Argon2/core.c

@@ -86,7 +86,7 @@ static void store_block(void *output, const block *src) {
 
 /***************Memory functions*****************/
 
-int allocate_memory(const argon2_context *context, uint8_t **memory,
+int allocate_memory(const argon2_context_t *context, uint8_t **memory,
                     size_t num, size_t size) {
     size_t memory_size = num*size;
     if (memory == NULL) {
@@ -112,7 +112,7 @@ int allocate_memory(const argon2_context *context, uint8_t **memory,
     return ARGON2_OK;
 }
 
-void free_memory(const argon2_context *context, uint8_t *memory,
+void free_memory(const argon2_context_t *context, uint8_t *memory,
                  size_t num, size_t size) {
     size_t memory_size = num*size;
     clear_internal_memory(memory, memory_size);
@@ -152,7 +152,7 @@ void clear_internal_memory(void *v, size_t n) {
   }
 }
 
-void finalize(const argon2_context *context, argon2_instance_t *instance) {
+void finalize(const argon2_context_t *context, argon2_instance_t *instance) {
     if (context != NULL && instance != NULL) {
         block blockhash;
         uint32_t l;
@@ -170,7 +170,7 @@ void finalize(const argon2_context *context, argon2_instance_t *instance) {
         {
             uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE];
             store_block(blockhash_bytes, &blockhash);
-            blake2b_long(context->out, context->outlen, blockhash_bytes,
+            kp_blake2b_long(context->out, context->outlen, blockhash_bytes,
                          ARGON2_BLOCK_SIZE);
             /* clear blockhash and blockhash_bytes */
             clear_internal_memory(blockhash.v, ARGON2_BLOCK_SIZE);
@@ -318,7 +318,7 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
 
                 /* 2.1 Join a thread if limit is exceeded */
                 if (l >= instance->threads) {
-                    if (argon2_thread_join(thread[l - instance->threads])) {
+                    if (kp_argon2_thread_join(thread[l - instance->threads])) {
                         rc = ARGON2_THREAD_FAIL;
                         goto fail;
                     }
@@ -333,11 +333,11 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
                     instance; /* preparing the thread input */
                 memcpy(&(thr_data[l].pos), &position,
                        sizeof(argon2_position_t));
-                if (argon2_thread_create(&thread[l], &fill_segment_thr,
+                if (kp_argon2_thread_create(&thread[l], &fill_segment_thr,
                                          (void *)&thr_data[l])) {
                     /* Wait for already running threads */
                     for (ll = 0; ll < l; ++ll)
-                        argon2_thread_join(thread[ll]);
+                        kp_argon2_thread_join(thread[ll]);
                     rc = ARGON2_THREAD_FAIL;
                     goto fail;
                 }
@@ -349,7 +349,7 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
             /* 3. Joining remaining threads */
             for (l = instance->lanes - instance->threads; l < instance->lanes;
                  ++l) {
-                if (argon2_thread_join(thread[l])) {
+                if (kp_argon2_thread_join(thread[l])) {
                     rc = ARGON2_THREAD_FAIL;
                     goto fail;
                 }
@@ -385,7 +385,7 @@ int fill_memory_blocks(argon2_instance_t *instance) {
 #endif
 }
 
-int validate_inputs(const argon2_context *context) {
+int validate_inputs(const argon2_context_t *context) {
     if (NULL == context) {
         return ARGON2_INCORRECT_PARAMETER;
     }
@@ -521,13 +521,13 @@ void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance) {
 
         store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 0);
         store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH + 4, l);
-        blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash,
+        kp_blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash,
                      ARGON2_PREHASH_SEED_LENGTH);
         load_block(&instance->memory[l * instance->lane_length + 0],
                    blockhash_bytes);
 
         store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 1);
-        blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash,
+        kp_blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash,
                      ARGON2_PREHASH_SEED_LENGTH);
         load_block(&instance->memory[l * instance->lane_length + 1],
                    blockhash_bytes);
@@ -535,8 +535,8 @@ void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance) {
     clear_internal_memory(blockhash_bytes, ARGON2_BLOCK_SIZE);
 }
 
-void initial_hash(uint8_t *blockhash, argon2_context *context,
-                  argon2_type type) {
+void initial_hash(uint8_t *blockhash, argon2_context_t *context,
+                  argon2_type_t type) {
     blake2b_state BlakeHash;
     uint8_t value[sizeof(uint32_t)];
 
@@ -544,31 +544,31 @@ void initial_hash(uint8_t *blockhash, argon2_context *context,
         return;
     }
 
-    blake2b_init(&BlakeHash, ARGON2_PREHASH_DIGEST_LENGTH);
+    kp_blake2b_init(&BlakeHash, ARGON2_PREHASH_DIGEST_LENGTH);
 
     store32(&value, context->lanes);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     store32(&value, context->outlen);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     store32(&value, context->m_cost);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     store32(&value, context->t_cost);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     store32(&value, context->version);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     store32(&value, (uint32_t)type);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     store32(&value, context->pwdlen);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     if (context->pwd != NULL) {
-        blake2b_update(&BlakeHash, (const uint8_t *)context->pwd,
+        kp_blake2b_update(&BlakeHash, (const uint8_t *)context->pwd,
                        context->pwdlen);
 
         if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) {
@@ -578,18 +578,18 @@ void initial_hash(uint8_t *blockhash, argon2_context *context,
     }
 
     store32(&value, context->saltlen);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     if (context->salt != NULL) {
-        blake2b_update(&BlakeHash, (const uint8_t *)context->salt,
+        kp_blake2b_update(&BlakeHash, (const uint8_t *)context->salt,
                        context->saltlen);
     }
 
     store32(&value, context->secretlen);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     if (context->secret != NULL) {
-        blake2b_update(&BlakeHash, (const uint8_t *)context->secret,
+        kp_blake2b_update(&BlakeHash, (const uint8_t *)context->secret,
                        context->secretlen);
 
         if (context->flags & ARGON2_FLAG_CLEAR_SECRET) {
@@ -599,17 +599,17 @@ void initial_hash(uint8_t *blockhash, argon2_context *context,
     }
 
     store32(&value, context->adlen);
-    blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
+    kp_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
 
     if (context->ad != NULL) {
-        blake2b_update(&BlakeHash, (const uint8_t *)context->ad,
+        kp_blake2b_update(&BlakeHash, (const uint8_t *)context->ad,
                        context->adlen);
     }
 
-    blake2b_final(&BlakeHash, blockhash, ARGON2_PREHASH_DIGEST_LENGTH);
+    kp_blake2b_final(&BlakeHash, blockhash, ARGON2_PREHASH_DIGEST_LENGTH);
 }
 
-int initialize(argon2_instance_t *instance, argon2_context *context) {
+int initialize(argon2_instance_t *instance, argon2_context_t *context) {
     uint8_t blockhash[ARGON2_PREHASH_SEED_LENGTH];
     int result = ARGON2_OK;
 

+ 5 - 5
Sources/Argon2/encoding.c

@@ -255,7 +255,7 @@ static const char *decode_decimal(const char *str, unsigned long *v) {
  * when it is fed into decode_string.
  */
 
-int decode_string(argon2_context *ctx, const char *str, argon2_type type) {
+int decode_string(argon2_context_t *ctx, const char *str, argon2_type_t type) {
 
 /* check for prefix */
 #define CC(prefix)                                                             \
@@ -318,7 +318,7 @@ int decode_string(argon2_context *ctx, const char *str, argon2_type type) {
     const char* type_string;
 
     /* We should start with the argon2_type we are using */
-    type_string = argon2_type2string(type, 0);
+    type_string = kp_argon2_type2string(type, 0);
     if (!type_string) {
         return ARGON2_INCORRECT_TYPE;
     }
@@ -370,8 +370,8 @@ int decode_string(argon2_context *ctx, const char *str, argon2_type type) {
 #undef BIN
 }
 
-int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
-                  argon2_type type) {
+int encode_string(char *dst, size_t dst_len, argon2_context_t *ctx,
+                  argon2_type_t type) {
 #define SS(str)                                                                \
     do {                                                                       \
         size_t pp_len = strlen(str);                                           \
@@ -400,7 +400,7 @@ int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
         dst_len -= sb_len;                                                     \
     } while ((void)0, 0)
 
-    const char* type_string = argon2_type2string(type, 0);
+    const char* type_string = kp_argon2_type2string(type, 0);
     int validation_result = validate_inputs(ctx);
 
     if (!type_string) {

+ 71 - 71
Sources/Argon2/include/argon2.h

@@ -97,7 +97,7 @@ extern "C" {
 extern int FLAG_clear_internal_memory;
 
 /* Error codes */
-typedef enum Argon2_ErrorCodes {
+typedef enum argon2_error_codes {
     ARGON2_OK = 0,
 
     ARGON2_OUTPUT_PTR_NULL = -1,
@@ -155,7 +155,7 @@ typedef enum Argon2_ErrorCodes {
     ARGON2_DECODING_LENGTH_FAIL = -34,
 
     ARGON2_VERIFY_MISMATCH = -35
-} argon2_error_codes;
+} argon2_error_codes_t;
 
 /* Memory allocator types --- for external allocation */
 typedef int (*allocate_fptr)(uint8_t **memory, size_t bytes_to_allocate);
@@ -188,7 +188,7 @@ typedef void (*deallocate_fptr)(uint8_t *memory, size_t bytes_to_allocate);
  * Then you initialize:
  Argon2_Context(out,8,pwd,32,salt,16,NULL,0,NULL,0,5,1<<20,4,4,NULL,NULL,true,false,false,false)
  */
-typedef struct Argon2_Context {
+typedef struct argon2_context {
     uint8_t *out;    /* output array */
     uint32_t outlen; /* digest length */
 
@@ -215,21 +215,21 @@ typedef struct Argon2_Context {
     deallocate_fptr free_cbk;   /* pointer to memory deallocator */
 
     uint32_t flags; /* array of bool options */
-} argon2_context;
+} argon2_context_t;
 
 /* Argon2 primitive type */
-typedef enum Argon2_type {
+typedef enum argon2_type {
   Argon2_d = 0,
   Argon2_i = 1,
   Argon2_id = 2
-} argon2_type;
+} argon2_type_t;
 
 /* Version of the algorithm */
-typedef enum Argon2_version {
+typedef enum argon2_version {
     ARGON2_VERSION_10 = 0x10,
     ARGON2_VERSION_13 = 0x13,
     ARGON2_VERSION_NUMBER = ARGON2_VERSION_13
-} argon2_version;
+} argon2_version_t;
 
 /*
  * Function that gives the string representation of an argon2_type.
@@ -237,14 +237,14 @@ typedef enum Argon2_version {
  * @param uppercase Whether the string should have the first letter uppercase
  * @return NULL if invalid type, otherwise the string representation.
  */
-ARGON2_PUBLIC const char *argon2_type2string(argon2_type type, int uppercase);
+ARGON2_PUBLIC const char *kp_argon2_type2string(argon2_type_t type, int uppercase);
 
 /*
  * Function that performs memory-hard hashing with certain degree of parallelism
  * @param  context  Pointer to the Argon2 internal structure
  * @return Error code if smth is wrong, ARGON2_OK otherwise
  */
-ARGON2_PUBLIC int argon2_ctx(argon2_context *context, argon2_type type);
+ARGON2_PUBLIC int kp_argon2_ctx(argon2_context_t *context, argon2_type_t type);
 
 /**
  * Hashes a password with Argon2i, producing an encoded hash
@@ -261,7 +261,7 @@ ARGON2_PUBLIC int argon2_ctx(argon2_context *context, argon2_type type);
  * @pre   Different parallelism levels will give different results
  * @pre   Returns ARGON2_OK if successful
  */
-ARGON2_PUBLIC int argon2i_hash_encoded(const uint32_t t_cost,
+ARGON2_PUBLIC int kp_argon2i_hash_encoded(const uint32_t t_cost,
                                        const uint32_t m_cost,
                                        const uint32_t parallelism,
                                        const void *pwd, const size_t pwdlen,
@@ -283,49 +283,49 @@ ARGON2_PUBLIC int argon2i_hash_encoded(const uint32_t t_cost,
  * @pre   Different parallelism levels will give different results
  * @pre   Returns ARGON2_OK if successful
  */
-ARGON2_PUBLIC int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
-                                   const uint32_t parallelism, const void *pwd,
-                                   const size_t pwdlen, const void *salt,
-                                   const size_t saltlen, void *hash,
-                                   const size_t hashlen);
-
-ARGON2_PUBLIC int argon2d_hash_encoded(const uint32_t t_cost,
+ARGON2_PUBLIC int kp_argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
+                                      const uint32_t parallelism, const void *pwd,
+                                      const size_t pwdlen, const void *salt,
+                                      const size_t saltlen, void *hash,
+                                      const size_t hashlen);
+
+ARGON2_PUBLIC int kp_argon2d_hash_encoded(const uint32_t t_cost,
+                                          const uint32_t m_cost,
+                                          const uint32_t parallelism,
+                                          const void *pwd, const size_t pwdlen,
+                                          const void *salt, const size_t saltlen,
+                                          const size_t hashlen, char *encoded,
+                                          const size_t encodedlen);
+
+ARGON2_PUBLIC int kp_argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
+                                      const uint32_t parallelism, const void *pwd,
+                                      const size_t pwdlen, const void *salt,
+                                      const size_t saltlen, void *hash,
+                                      const size_t hashlen);
+
+ARGON2_PUBLIC int kp_argon2id_hash_encoded(const uint32_t t_cost,
+                                           const uint32_t m_cost,
+                                           const uint32_t parallelism,
+                                           const void *pwd, const size_t pwdlen,
+                                           const void *salt, const size_t saltlen,
+                                           const size_t hashlen, char *encoded,
+                                           const size_t encodedlen);
+
+ARGON2_PUBLIC int kp_argon2id_hash_raw(const uint32_t t_cost,
                                        const uint32_t m_cost,
-                                       const uint32_t parallelism,
-                                       const void *pwd, const size_t pwdlen,
-                                       const void *salt, const size_t saltlen,
-                                       const size_t hashlen, char *encoded,
-                                       const size_t encodedlen);
-
-ARGON2_PUBLIC int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
-                                   const uint32_t parallelism, const void *pwd,
-                                   const size_t pwdlen, const void *salt,
-                                   const size_t saltlen, void *hash,
-                                   const size_t hashlen);
-
-ARGON2_PUBLIC int argon2id_hash_encoded(const uint32_t t_cost,
-                                        const uint32_t m_cost,
-                                        const uint32_t parallelism,
-                                        const void *pwd, const size_t pwdlen,
-                                        const void *salt, const size_t saltlen,
-                                        const size_t hashlen, char *encoded,
-                                        const size_t encodedlen);
-
-ARGON2_PUBLIC int argon2id_hash_raw(const uint32_t t_cost,
-                                    const uint32_t m_cost,
-                                    const uint32_t parallelism, const void *pwd,
-                                    const size_t pwdlen, const void *salt,
-                                    const size_t saltlen, void *hash,
-                                    const size_t hashlen);
+                                       const uint32_t parallelism, const void *pwd,
+                                       const size_t pwdlen, const void *salt,
+                                       const size_t saltlen, void *hash,
+                                       const size_t hashlen);
 
 /* generic function underlying the above ones */
-ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
-                              const uint32_t parallelism, const void *pwd,
-                              const size_t pwdlen, const void *salt,
-                              const size_t saltlen, void *hash,
-                              const size_t hashlen, char *encoded,
-                              const size_t encodedlen, argon2_type type,
-                              const uint32_t version);
+ARGON2_PUBLIC int kp_argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
+                                 const uint32_t parallelism, const void *pwd,
+                                 const size_t pwdlen, const void *salt,
+                                 const size_t saltlen, void *hash,
+                                 const size_t hashlen, char *encoded,
+                                 const size_t encodedlen, argon2_type_t type,
+                                 const uint32_t version);
 
 /**
  * Verifies a password against an encoded string
@@ -334,18 +334,18 @@ ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
  * @param pwd Pointer to password
  * @pre   Returns ARGON2_OK if successful
  */
-ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd,
-                                 const size_t pwdlen);
+ARGON2_PUBLIC int kp_argon2i_verify(const char *encoded, const void *pwd,
+                                    const size_t pwdlen);
 
-ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd,
-                                 const size_t pwdlen);
+ARGON2_PUBLIC int kp_argon2d_verify(const char *encoded, const void *pwd,
+                                    const size_t pwdlen);
 
-ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd,
-                                  const size_t pwdlen);
+ARGON2_PUBLIC int kp_argon2id_verify(const char *encoded, const void *pwd,
+                                     const size_t pwdlen);
 
 /* generic function underlying the above ones */
-ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd,
-                                const size_t pwdlen, argon2_type type);
+ARGON2_PUBLIC int kp_argon2_verify(const char *encoded, const void *pwd,
+                                   const size_t pwdlen, argon2_type_t type);
 
 /**
  * Argon2d: Version of Argon2 that picks memory blocks depending
@@ -355,7 +355,7 @@ ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd,
  * @param  context  Pointer to current Argon2 context
  * @return  Zero if successful, a non zero error code otherwise
  */
-ARGON2_PUBLIC int argon2d_ctx(argon2_context *context);
+ARGON2_PUBLIC int kp_argon2d_ctx(argon2_context_t *context);
 
 /**
  * Argon2i: Version of Argon2 that picks memory blocks
@@ -365,7 +365,7 @@ ARGON2_PUBLIC int argon2d_ctx(argon2_context *context);
  * @param  context  Pointer to current Argon2 context
  * @return  Zero if successful, a non zero error code otherwise
  */
-ARGON2_PUBLIC int argon2i_ctx(argon2_context *context);
+ARGON2_PUBLIC int kp_argon2i_ctx(argon2_context_t *context);
 
 /**
  * Argon2id: Version of Argon2 where the first half-pass over memory is
@@ -376,7 +376,7 @@ ARGON2_PUBLIC int argon2i_ctx(argon2_context *context);
  * @param  context  Pointer to current Argon2 context
  * @return  Zero if successful, a non zero error code otherwise
  */
-ARGON2_PUBLIC int argon2id_ctx(argon2_context *context);
+ARGON2_PUBLIC int kp_argon2id_ctx(argon2_context_t *context);
 
 /**
  * Verify if a given password is correct for Argon2d hashing
@@ -385,7 +385,7 @@ ARGON2_PUBLIC int argon2id_ctx(argon2_context *context);
  * specified by the context outlen member
  * @return  Zero if successful, a non zero error code otherwise
  */
-ARGON2_PUBLIC int argon2d_verify_ctx(argon2_context *context, const char *hash);
+ARGON2_PUBLIC int kp_argon2d_verify_ctx(argon2_context_t *context, const char *hash);
 
 /**
  * Verify if a given password is correct for Argon2i hashing
@@ -394,7 +394,7 @@ ARGON2_PUBLIC int argon2d_verify_ctx(argon2_context *context, const char *hash);
  * specified by the context outlen member
  * @return  Zero if successful, a non zero error code otherwise
  */
-ARGON2_PUBLIC int argon2i_verify_ctx(argon2_context *context, const char *hash);
+ARGON2_PUBLIC int kp_argon2i_verify_ctx(argon2_context_t *context, const char *hash);
 
 /**
  * Verify if a given password is correct for Argon2id hashing
@@ -403,18 +403,18 @@ ARGON2_PUBLIC int argon2i_verify_ctx(argon2_context *context, const char *hash);
  * specified by the context outlen member
  * @return  Zero if successful, a non zero error code otherwise
  */
-ARGON2_PUBLIC int argon2id_verify_ctx(argon2_context *context,
+ARGON2_PUBLIC int kp_argon2id_verify_ctx(argon2_context_t *context,
                                       const char *hash);
 
 /* generic function underlying the above ones */
-ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash,
-                                    argon2_type type);
+ARGON2_PUBLIC int kp_argon2_verify_ctx(argon2_context_t *context, const char *hash,
+                                    argon2_type_t type);
 
 /**
  * Get the associated error message for given error code
  * @return  The error message associated with the given error code
  */
-ARGON2_PUBLIC const char *argon2_error_message(int error_code);
+ARGON2_PUBLIC const char *kp_argon2_error_message(int error_code);
 
 /**
  * Returns the encoded hash length for the given input parameters
@@ -426,9 +426,9 @@ ARGON2_PUBLIC const char *argon2_error_message(int error_code);
  * @param type The argon2_type that we want the encoded length for
  * @return  The encoded hash length in bytes
  */
-ARGON2_PUBLIC size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost,
-                                       uint32_t parallelism, uint32_t saltlen,
-                                       uint32_t hashlen, argon2_type type);
+ARGON2_PUBLIC size_t kp_argon2_encodedlen(uint32_t t_cost, uint32_t m_cost,
+                                          uint32_t parallelism, uint32_t saltlen,
+                                          uint32_t hashlen, argon2_type_t type);
 
 #if defined(__cplusplus)
 }

+ 7 - 7
Sources/Argon2/include/blake2/blake2.h

@@ -67,19 +67,19 @@ enum {
 };
 
 /* Streaming API */
-ARGON2_LOCAL int blake2b_init(blake2b_state *S, size_t outlen);
-ARGON2_LOCAL int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
+ARGON2_LOCAL int kp_blake2b_init(blake2b_state *S, size_t outlen);
+ARGON2_LOCAL int kp_blake2b_init_key(blake2b_state *S, size_t outlen, const void *key,
                      size_t keylen);
-ARGON2_LOCAL int blake2b_init_param(blake2b_state *S, const blake2b_param *P);
-ARGON2_LOCAL int blake2b_update(blake2b_state *S, const void *in, size_t inlen);
-ARGON2_LOCAL int blake2b_final(blake2b_state *S, void *out, size_t outlen);
+ARGON2_LOCAL int kp_blake2b_init_param(blake2b_state *S, const blake2b_param *P);
+ARGON2_LOCAL int kp_blake2b_update(blake2b_state *S, const void *in, size_t inlen);
+ARGON2_LOCAL int kp_blake2b_final(blake2b_state *S, void *out, size_t outlen);
 
 /* Simple API */
-ARGON2_LOCAL int blake2b(void *out, size_t outlen, const void *in, size_t inlen,
+ARGON2_LOCAL int vblake2b(void *out, size_t outlen, const void *in, size_t inlen,
                          const void *key, size_t keylen);
 
 /* Argon2 Team - Begin Code */
-ARGON2_LOCAL int blake2b_long(void *out, size_t outlen, const void *in, size_t inlen);
+ARGON2_LOCAL int kp_blake2b_long(void *out, size_t outlen, const void *in, size_t inlen);
 /* Argon2 Team - End Code */
 
 #if defined(__cplusplus)

+ 9 - 9
Sources/Argon2/include/core.h

@@ -77,9 +77,9 @@ typedef struct Argon2_instance_t {
     uint32_t lane_length;
     uint32_t lanes;
     uint32_t threads;
-    argon2_type type;
+    argon2_type_t type;
     int print_internals; /* whether to print the memory blocks */
-    argon2_context *context_ptr; /* points back to original context */
+    argon2_context_t *context_ptr; /* points back to original context */
 } argon2_instance_t;
 
 /*
@@ -109,7 +109,7 @@ typedef struct Argon2_thread_data {
  * @param num the number of elements to be allocated
  * @return ARGON2_OK if @memory is a valid pointer and memory is allocated
  */
-int allocate_memory(const argon2_context *context, uint8_t **memory,
+int allocate_memory(const argon2_context_t *context, uint8_t **memory,
                     size_t num, size_t size);
 
 /*
@@ -120,7 +120,7 @@ int allocate_memory(const argon2_context *context, uint8_t **memory,
  * @param size the size in bytes for each element to be deallocated
  * @param num the number of elements to be deallocated
  */
-void free_memory(const argon2_context *context, uint8_t *memory,
+void free_memory(const argon2_context_t *context, uint8_t *memory,
                  size_t num, size_t size);
 
 /* Function that securely cleans the memory. This ignores any flags set
@@ -158,7 +158,7 @@ uint32_t index_alpha(const argon2_instance_t *instance,
  * @return ARGON2_OK if everything is all right, otherwise one of error codes
  * (all defined in <argon2.h>
  */
-int validate_inputs(const argon2_context *context);
+int validate_inputs(const argon2_context_t *context);
 
 /*
  * Hashes all the inputs into @a blockhash[PREHASH_DIGEST_LENGTH], clears
@@ -170,8 +170,8 @@ int validate_inputs(const argon2_context *context);
  * @pre    @a blockhash must have at least @a PREHASH_DIGEST_LENGTH bytes
  * allocated
  */
-void initial_hash(uint8_t *blockhash, argon2_context *context,
-                  argon2_type type);
+void initial_hash(uint8_t *blockhash, argon2_context_t *context,
+                  argon2_type_t type);
 
 /*
  * Function creates first 2 blocks per lane
@@ -191,7 +191,7 @@ void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance);
  * @return Zero if successful, -1 if memory failed to allocate. @context->state
  * will be modified if successful.
  */
-int initialize(argon2_instance_t *instance, argon2_context *context);
+int initialize(argon2_instance_t *instance, argon2_context_t *context);
 
 /*
  * XORing the last block of each lane, hashing it, making the tag. Deallocates
@@ -204,7 +204,7 @@ int initialize(argon2_instance_t *instance, argon2_context *context);
  * @pre if context->free_cbk is not NULL, it should point to a function that
  * deallocates memory
  */
-void finalize(const argon2_context *context, argon2_instance_t *instance);
+void finalize(const argon2_context_t *context, argon2_instance_t *instance);
 
 /*
  * Function that fills the segment using previous segments also from other

+ 3 - 3
Sources/Argon2/include/encoding.h

@@ -31,8 +31,8 @@
 *
 * on success, ARGON2_OK is returned.
 */
-int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
-                  argon2_type type);
+int encode_string(char *dst, size_t dst_len, argon2_context_t *ctx,
+                  argon2_type_t type);
 
 /*
 * Decodes an Argon2 hash string into the provided structure 'ctx'.
@@ -46,7 +46,7 @@ int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
 *
 * Returned value is ARGON2_OK on success, other ARGON2_ codes on error.
 */
-int decode_string(argon2_context *ctx, const char *str, argon2_type type);
+int decode_string(argon2_context_t *ctx, const char *str, argon2_type_t type);
 
 /* Returns the length of the encoded byte stream with length len */
 size_t b64len(uint32_t len);

+ 3 - 3
Sources/Argon2/include/thread.h

@@ -49,14 +49,14 @@ typedef pthread_t argon2_thread_handle_t;
  * @return 0 if @handle and @func are valid pointers and a thread is successfully
  * created.
  */
-int argon2_thread_create(argon2_thread_handle_t *handle,
-                         argon2_thread_func_t func, void *args);
+int kp_argon2_thread_create(argon2_thread_handle_t *handle,
+                            argon2_thread_func_t func, void *args);
 
 /* Waits for a thread to terminate
  * @param handle Handle to a thread created with argon2_thread_create.
  * @return 0 if @handle is a valid handle, and joining completed successfully.
 */
-int argon2_thread_join(argon2_thread_handle_t handle);
+int kp_argon2_thread_join(argon2_thread_handle_t handle);
 
 /* Terminate the current thread. Must be run inside a thread created by
  * argon2_thread_create.

+ 2 - 2
Sources/Argon2/thread.c

@@ -22,7 +22,7 @@
 #include <windows.h>
 #endif
 
-int argon2_thread_create(argon2_thread_handle_t *handle,
+int kp_argon2_thread_create(argon2_thread_handle_t *handle,
                          argon2_thread_func_t func, void *args) {
     if (NULL == handle || func == NULL) {
         return -1;
@@ -35,7 +35,7 @@ int argon2_thread_create(argon2_thread_handle_t *handle,
 #endif
 }
 
-int argon2_thread_join(argon2_thread_handle_t handle) {
+int kp_argon2_thread_join(argon2_thread_handle_t handle) {
 #if defined(_WIN32)
     if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) {
         return CloseHandle((HANDLE)handle) != 0 ? 0 : -1;