mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
pwdbased updated
This commit is contained in:
@@ -23,11 +23,11 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
|
|
||||||
#ifndef NO_PWDBASED
|
#ifndef NO_PWDBASED
|
||||||
|
|
||||||
#ifdef CYASSL_PIC32MZ_HASH
|
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||||
|
|
||||||
#define InitMd5 InitMd5_sw
|
#define InitMd5 InitMd5_sw
|
||||||
#define Md5Update Md5Update_sw
|
#define Md5Update Md5Update_sw
|
||||||
@@ -43,18 +43,18 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/pwdbased.h>
|
#include <wolfssl/wolfcrypt/pwdbased.h>
|
||||||
#include <cyassl/ctaocrypt/hmac.h>
|
#include <wolfssl/wolfcrypt/hmac.h>
|
||||||
#include <cyassl/ctaocrypt/integer.h>
|
#include <wolfssl/wolfcrypt/integer.h>
|
||||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||||
#if defined(CYASSL_SHA512) || defined(CYASSL_SHA384)
|
#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384)
|
||||||
#include <cyassl/ctaocrypt/sha512.h>
|
#include <wolfssl/wolfcrypt/sha512.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NO_INLINE
|
#ifdef NO_INLINE
|
||||||
#include <cyassl/ctaocrypt/misc.h>
|
#include <wolfssl/wolfcrypt/misc.h>
|
||||||
#else
|
#else
|
||||||
#include <ctaocrypt/src/misc.c>
|
#include <wolfcrypt/src/misc.c>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
#endif /* min */
|
#endif /* min */
|
||||||
|
|
||||||
|
|
||||||
int PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt,
|
int wc_PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt,
|
||||||
int sLen, int iterations, int kLen, int hashType)
|
int sLen, int iterations, int kLen, int hashType)
|
||||||
{
|
{
|
||||||
Md5 md5;
|
Md5 md5;
|
||||||
@@ -117,14 +117,14 @@ int PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
||||||
int sLen, int iterations, int kLen, int hashType)
|
int sLen, int iterations, int kLen, int hashType)
|
||||||
{
|
{
|
||||||
word32 i = 1;
|
word32 i = 1;
|
||||||
int hLen;
|
int hLen;
|
||||||
int j, ret;
|
int j, ret;
|
||||||
Hmac hmac;
|
Hmac hmac;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
byte* buffer;
|
byte* buffer;
|
||||||
#else
|
#else
|
||||||
byte buffer[MAX_DIGEST_SIZE];
|
byte buffer[MAX_DIGEST_SIZE];
|
||||||
@@ -141,7 +141,7 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
|||||||
hLen = SHA256_DIGEST_SIZE;
|
hLen = SHA256_DIGEST_SIZE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CYASSL_SHA512
|
#ifdef WOLFSSL_SHA512
|
||||||
else if (hashType == SHA512) {
|
else if (hashType == SHA512) {
|
||||||
hLen = SHA512_DIGEST_SIZE;
|
hLen = SHA512_DIGEST_SIZE;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
|||||||
else
|
else
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
buffer = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
buffer = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
@@ -205,14 +205,14 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SHA512
|
#ifdef WOLFSSL_SHA512
|
||||||
#define PBKDF_DIGEST_SIZE SHA512_BLOCK_SIZE
|
#define PBKDF_DIGEST_SIZE SHA512_BLOCK_SIZE
|
||||||
#elif !defined(NO_SHA256)
|
#elif !defined(NO_SHA256)
|
||||||
#define PBKDF_DIGEST_SIZE SHA256_BLOCK_SIZE
|
#define PBKDF_DIGEST_SIZE SHA256_BLOCK_SIZE
|
||||||
@@ -220,7 +220,7 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
|||||||
#define PBKDF_DIGEST_SIZE SHA_DIGEST_SIZE
|
#define PBKDF_DIGEST_SIZE SHA_DIGEST_SIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
||||||
int saltLen, int iterations, int kLen, int hashType, int id)
|
int saltLen, int iterations, int kLen, int hashType, int id)
|
||||||
{
|
{
|
||||||
/* all in bytes instead of bits */
|
/* all in bytes instead of bits */
|
||||||
@@ -229,14 +229,14 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
byte *D, *S, *P, *I;
|
byte *D, *S, *P, *I;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
byte staticBuffer[1]; /* force dynamic usage */
|
byte staticBuffer[1]; /* force dynamic usage */
|
||||||
#else
|
#else
|
||||||
byte staticBuffer[1024];
|
byte staticBuffer[1024];
|
||||||
#endif
|
#endif
|
||||||
byte* buffer = staticBuffer;
|
byte* buffer = staticBuffer;
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
byte* Ai;
|
byte* Ai;
|
||||||
byte* B;
|
byte* B;
|
||||||
#else
|
#else
|
||||||
@@ -261,7 +261,7 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
|||||||
u = SHA256_DIGEST_SIZE;
|
u = SHA256_DIGEST_SIZE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CYASSL_SHA512
|
#ifdef WOLFSSL_SHA512
|
||||||
else if (hashType == SHA512) {
|
else if (hashType == SHA512) {
|
||||||
v = SHA512_BLOCK_SIZE;
|
v = SHA512_BLOCK_SIZE;
|
||||||
u = SHA512_DIGEST_SIZE;
|
u = SHA512_DIGEST_SIZE;
|
||||||
@@ -270,7 +270,7 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
|||||||
else
|
else
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
Ai = (byte*)XMALLOC(PBKDF_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
Ai = (byte*)XMALLOC(PBKDF_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (Ai == NULL)
|
if (Ai == NULL)
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
@@ -295,7 +295,7 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
|||||||
if (totalLen > sizeof(staticBuffer)) {
|
if (totalLen > sizeof(staticBuffer)) {
|
||||||
buffer = (byte*)XMALLOC(totalLen, 0, DYNAMIC_TYPE_KEY);
|
buffer = (byte*)XMALLOC(totalLen, 0, DYNAMIC_TYPE_KEY);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(B, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(B, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
@@ -373,7 +373,7 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CYASSL_SHA512
|
#ifdef WOLFSSL_SHA512
|
||||||
else if (hashType == SHA512) {
|
else if (hashType == SHA512) {
|
||||||
Sha512 sha512;
|
Sha512 sha512;
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
|
|||||||
|
|
||||||
if (dynamic) XFREE(buffer, 0, DYNAMIC_TYPE_KEY);
|
if (dynamic) XFREE(buffer, 0, DYNAMIC_TYPE_KEY);
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(Ai, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(B, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(B, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2,14 +2,14 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of CyaSSL.
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
*
|
*
|
||||||
* CyaSSL is free software; you can redistribute it and/or modify
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* CyaSSL is distributed in the hope that it will be useful,
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
@@ -22,25 +22,26 @@
|
|||||||
|
|
||||||
#ifndef NO_PWDBASED
|
#ifndef NO_PWDBASED
|
||||||
|
|
||||||
#ifndef CTAO_CRYPT_PWDBASED_H
|
#ifndef WOLF_CRYPT_PWDBASED_H
|
||||||
#define CTAO_CRYPT_PWDBASED_H
|
#define WOLF_CRYPT_PWDBASED_H
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/types.h>
|
#include <cyassl/ctaocrypt/types.h>
|
||||||
#include <cyassl/ctaocrypt/md5.h> /* for hash type */
|
|
||||||
#include <cyassl/ctaocrypt/sha.h>
|
/* included for fips @wc_fips */
|
||||||
|
#include <cyassl/ctaocrypt/pwdbased.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
CYASSL_API int PBKDF1(byte* output, const byte* passwd, int pLen,
|
WOLFSSL_API int wc_PBKDF1(byte* output, const byte* passwd, int pLen,
|
||||||
const byte* salt, int sLen, int iterations, int kLen,
|
const byte* salt, int sLen, int iterations, int kLen,
|
||||||
int hashType);
|
int hashType);
|
||||||
CYASSL_API int PBKDF2(byte* output, const byte* passwd, int pLen,
|
WOLFSSL_API int wc_PBKDF2(byte* output, const byte* passwd, int pLen,
|
||||||
const byte* salt, int sLen, int iterations, int kLen,
|
const byte* salt, int sLen, int iterations, int kLen,
|
||||||
int hashType);
|
int hashType);
|
||||||
CYASSL_API int PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
|
WOLFSSL_API int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
|
||||||
const byte* salt, int sLen, int iterations,
|
const byte* salt, int sLen, int iterations,
|
||||||
int kLen, int hashType, int purpose);
|
int kLen, int hashType, int purpose);
|
||||||
|
|
||||||
@@ -49,5 +50,5 @@ CYASSL_API int PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
|
|||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CTAO_CRYPT_PWDBASED_H */
|
#endif /* WOLF_CRYPT_PWDBASED_H */
|
||||||
#endif /* NO_PWDBASED */
|
#endif /* NO_PWDBASED */
|
||||||
|
Reference in New Issue
Block a user