mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
switch RC2 struct name to Rc2 for consistent camel case across algorithms
This commit is contained in:
18
tests/api.c
18
tests/api.c
@ -11866,7 +11866,7 @@ static int test_wc_Rc2SetKey(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef WC_RC2
|
#ifdef WC_RC2
|
||||||
RC2 rc2;
|
Rc2 rc2;
|
||||||
byte key40[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
byte key40[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||||
byte iv[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
byte iv[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
||||||
|
|
||||||
@ -11883,7 +11883,7 @@ static int test_wc_Rc2SetKey(void)
|
|||||||
|
|
||||||
/* bad arguments */
|
/* bad arguments */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* null RC2 struct */
|
/* null Rc2 struct */
|
||||||
ret = wc_Rc2SetKey(NULL, key40, (word32) sizeof(key40) / sizeof(byte),
|
ret = wc_Rc2SetKey(NULL, key40, (word32) sizeof(key40) / sizeof(byte),
|
||||||
iv, 40);
|
iv, 40);
|
||||||
if (ret == BAD_FUNC_ARG) {
|
if (ret == BAD_FUNC_ARG) {
|
||||||
@ -11947,7 +11947,7 @@ static int test_wc_Rc2SetIV(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef WC_RC2
|
#ifdef WC_RC2
|
||||||
RC2 rc2;
|
Rc2 rc2;
|
||||||
byte iv[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
byte iv[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
||||||
|
|
||||||
printf(testingFmt, "wc_Rc2SetIV()");
|
printf(testingFmt, "wc_Rc2SetIV()");
|
||||||
@ -11980,7 +11980,7 @@ static int test_wc_Rc2EcbEncryptDecrypt(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef WC_RC2
|
#ifdef WC_RC2
|
||||||
RC2 rc2;
|
Rc2 rc2;
|
||||||
int effectiveKeyBits = 63;
|
int effectiveKeyBits = 63;
|
||||||
|
|
||||||
byte cipher[RC2_BLOCK_SIZE];
|
byte cipher[RC2_BLOCK_SIZE];
|
||||||
@ -12013,7 +12013,7 @@ static int test_wc_Rc2EcbEncryptDecrypt(void)
|
|||||||
|
|
||||||
/* Rc2EcbEncrypt bad arguments */
|
/* Rc2EcbEncrypt bad arguments */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* null RC2 struct */
|
/* null Rc2 struct */
|
||||||
ret = wc_Rc2EcbEncrypt(NULL, cipher, input, RC2_BLOCK_SIZE);
|
ret = wc_Rc2EcbEncrypt(NULL, cipher, input, RC2_BLOCK_SIZE);
|
||||||
if (ret == BAD_FUNC_ARG) {
|
if (ret == BAD_FUNC_ARG) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -12046,7 +12046,7 @@ static int test_wc_Rc2EcbEncryptDecrypt(void)
|
|||||||
|
|
||||||
/* Rc2EcbDecrypt bad arguments */
|
/* Rc2EcbDecrypt bad arguments */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* null RC2 struct */
|
/* null Rc2 struct */
|
||||||
ret = wc_Rc2EcbDecrypt(NULL, plain, output, RC2_BLOCK_SIZE);
|
ret = wc_Rc2EcbDecrypt(NULL, plain, output, RC2_BLOCK_SIZE);
|
||||||
if (ret == BAD_FUNC_ARG) {
|
if (ret == BAD_FUNC_ARG) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -12090,7 +12090,7 @@ static int test_wc_Rc2CbcEncryptDecrypt(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef WC_RC2
|
#ifdef WC_RC2
|
||||||
RC2 rc2;
|
Rc2 rc2;
|
||||||
int effectiveKeyBits = 63;
|
int effectiveKeyBits = 63;
|
||||||
|
|
||||||
byte cipher[RC2_BLOCK_SIZE*2];
|
byte cipher[RC2_BLOCK_SIZE*2];
|
||||||
@ -12138,7 +12138,7 @@ static int test_wc_Rc2CbcEncryptDecrypt(void)
|
|||||||
|
|
||||||
/* Rc2CbcEncrypt bad arguments */
|
/* Rc2CbcEncrypt bad arguments */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* null RC2 struct */
|
/* null Rc2 struct */
|
||||||
ret = wc_Rc2CbcEncrypt(NULL, cipher, input, sizeof(input));
|
ret = wc_Rc2CbcEncrypt(NULL, cipher, input, sizeof(input));
|
||||||
if (ret == BAD_FUNC_ARG) {
|
if (ret == BAD_FUNC_ARG) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -12171,7 +12171,7 @@ static int test_wc_Rc2CbcEncryptDecrypt(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* null RC2 struct */
|
/* null Rc2 struct */
|
||||||
ret = wc_Rc2CbcDecrypt(NULL, plain, output, sizeof(output));
|
ret = wc_Rc2CbcDecrypt(NULL, plain, output, sizeof(output));
|
||||||
if (ret == BAD_FUNC_ARG) {
|
if (ret == BAD_FUNC_ARG) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -85,7 +85,7 @@ static const byte pitable[256] = {
|
|||||||
iv IV, of size RC2_BLOCK_SIZE octets
|
iv IV, of size RC2_BLOCK_SIZE octets
|
||||||
return 0 on success, negative on error
|
return 0 on success, negative on error
|
||||||
*/
|
*/
|
||||||
int wc_Rc2SetIV(RC2* rc2, const byte* iv)
|
int wc_Rc2SetIV(Rc2* rc2, const byte* iv)
|
||||||
{
|
{
|
||||||
if (rc2 == NULL)
|
if (rc2 == NULL)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
@ -106,7 +106,7 @@ int wc_Rc2SetIV(RC2* rc2, const byte* iv)
|
|||||||
bits Effective RC2 key length in bits (max 1024 bits)
|
bits Effective RC2 key length in bits (max 1024 bits)
|
||||||
return 0 on success, negative on error
|
return 0 on success, negative on error
|
||||||
*/
|
*/
|
||||||
int wc_Rc2SetKey(RC2* rc2, const byte* key, word32 length,
|
int wc_Rc2SetKey(Rc2* rc2, const byte* key, word32 length,
|
||||||
const byte* iv, word32 bits)
|
const byte* iv, word32 bits)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -160,7 +160,7 @@ int wc_Rc2SetKey(RC2* rc2, const byte* key, word32 length,
|
|||||||
sz Size of the output buffer, out
|
sz Size of the output buffer, out
|
||||||
return 0 on success, negative on error
|
return 0 on success, negative on error
|
||||||
*/
|
*/
|
||||||
int wc_Rc2EcbEncrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
int wc_Rc2EcbEncrypt(Rc2* rc2, byte* out, const byte* in, word32 sz)
|
||||||
{
|
{
|
||||||
int i, j = 0;
|
int i, j = 0;
|
||||||
word16 r10, r32, r54, r76;
|
word16 r10, r32, r54, r76;
|
||||||
@ -225,7 +225,7 @@ int wc_Rc2EcbEncrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
|||||||
sz Size of the output buffer, out
|
sz Size of the output buffer, out
|
||||||
return 0 on success, negative on error
|
return 0 on success, negative on error
|
||||||
*/
|
*/
|
||||||
int wc_Rc2EcbDecrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
int wc_Rc2EcbDecrypt(Rc2* rc2, byte* out, const byte* in, word32 sz)
|
||||||
{
|
{
|
||||||
int i, j = 63;
|
int i, j = 63;
|
||||||
word16 r0, r1, r2, r3;
|
word16 r0, r1, r2, r3;
|
||||||
@ -280,7 +280,7 @@ int wc_Rc2EcbDecrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wc_Rc2CbcEncrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
int wc_Rc2CbcEncrypt(Rc2* rc2, byte* out, const byte* in, word32 sz)
|
||||||
{
|
{
|
||||||
word32 blocks = (sz / RC2_BLOCK_SIZE);
|
word32 blocks = (sz / RC2_BLOCK_SIZE);
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ int wc_Rc2CbcEncrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wc_Rc2CbcDecrypt(RC2* rc2, byte* out, const byte* in, word32 sz)
|
int wc_Rc2CbcDecrypt(Rc2* rc2, byte* out, const byte* in, word32 sz)
|
||||||
{
|
{
|
||||||
word32 blocks = (sz / RC2_BLOCK_SIZE);
|
word32 blocks = (sz / RC2_BLOCK_SIZE);
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt,
|
|||||||
#ifdef WC_RC2
|
#ifdef WC_RC2
|
||||||
case PBE_SHA1_40RC2_CBC:
|
case PBE_SHA1_40RC2_CBC:
|
||||||
{
|
{
|
||||||
RC2 rc2;
|
Rc2 rc2;
|
||||||
/* effective key size for RC2-40-CBC is 40 bits */
|
/* effective key size for RC2-40-CBC is 40 bits */
|
||||||
ret = wc_Rc2SetKey(&rc2, key, derivedLen, cbcIv, 40);
|
ret = wc_Rc2SetKey(&rc2, key, derivedLen, cbcIv, 40);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
@ -665,7 +665,7 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt,
|
|||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ForceZero(&rc2, sizeof(RC2));
|
ForceZero(&rc2, sizeof(Rc2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -4371,7 +4371,7 @@ static int rc2_ecb_test(void)
|
|||||||
test_rc2[7] = h;
|
test_rc2[7] = h;
|
||||||
|
|
||||||
for (i = 0; i < times; ++i) {
|
for (i = 0; i < times; ++i) {
|
||||||
RC2 enc;
|
Rc2 enc;
|
||||||
|
|
||||||
XMEMSET(cipher, 0, RC2_BLOCK_SIZE);
|
XMEMSET(cipher, 0, RC2_BLOCK_SIZE);
|
||||||
XMEMSET(plain, 0, RC2_BLOCK_SIZE);
|
XMEMSET(plain, 0, RC2_BLOCK_SIZE);
|
||||||
@ -4549,7 +4549,7 @@ static int rc2_cbc_test(void)
|
|||||||
test_rc2[8] = i;
|
test_rc2[8] = i;
|
||||||
|
|
||||||
for (j = 0; j < times; ++j) {
|
for (j = 0; j < times; ++j) {
|
||||||
RC2 rc2;
|
Rc2 rc2;
|
||||||
|
|
||||||
XMEMSET(cipher, 0, sizeof(cipher));
|
XMEMSET(cipher, 0, sizeof(cipher));
|
||||||
XMEMSET(plain, 0, sizeof(plain));
|
XMEMSET(plain, 0, sizeof(plain));
|
||||||
|
@ -36,28 +36,28 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* RC2 encryption and decryption */
|
/* RC2 encryption and decryption */
|
||||||
typedef struct RC2 {
|
typedef struct Rc2 {
|
||||||
word32 keylen; /* key length, octets */
|
word32 keylen; /* key length, octets */
|
||||||
word32 bits; /* effective key length, bits */
|
word32 bits; /* effective key length, bits */
|
||||||
ALIGN16 word16 key[RC2_MAX_KEY_SIZE/2];
|
ALIGN16 word16 key[RC2_MAX_KEY_SIZE/2];
|
||||||
ALIGN16 word32 reg[RC2_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
ALIGN16 word32 reg[RC2_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||||
ALIGN16 word32 tmp[RC2_BLOCK_SIZE / sizeof(word32)]; /* same */
|
ALIGN16 word32 tmp[RC2_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||||
} RC2;
|
} Rc2;
|
||||||
|
|
||||||
WOLFSSL_API int wc_Rc2SetKey(RC2* rc2, const byte* key, word32 length,
|
WOLFSSL_API int wc_Rc2SetKey(Rc2* rc2, const byte* key, word32 length,
|
||||||
const byte* iv, word32 bits);
|
const byte* iv, word32 bits);
|
||||||
WOLFSSL_API int wc_Rc2SetIV(RC2* rc2, const byte* iv);
|
WOLFSSL_API int wc_Rc2SetIV(Rc2* rc2, const byte* iv);
|
||||||
|
|
||||||
/* RC2-ECB */
|
/* RC2-ECB */
|
||||||
WOLFSSL_API int wc_Rc2EcbEncrypt(RC2* rc2, byte* out,
|
WOLFSSL_API int wc_Rc2EcbEncrypt(Rc2* rc2, byte* out,
|
||||||
const byte* in, word32 sz);
|
const byte* in, word32 sz);
|
||||||
WOLFSSL_API int wc_Rc2EcbDecrypt(RC2* rc2, byte* out,
|
WOLFSSL_API int wc_Rc2EcbDecrypt(Rc2* rc2, byte* out,
|
||||||
const byte* in, word32 sz);
|
const byte* in, word32 sz);
|
||||||
|
|
||||||
/* RC2-CBC */
|
/* RC2-CBC */
|
||||||
WOLFSSL_API int wc_Rc2CbcEncrypt(RC2* rc2, byte* out,
|
WOLFSSL_API int wc_Rc2CbcEncrypt(Rc2* rc2, byte* out,
|
||||||
const byte* in, word32 sz);
|
const byte* in, word32 sz);
|
||||||
WOLFSSL_API int wc_Rc2CbcDecrypt(RC2* rc2, byte* out,
|
WOLFSSL_API int wc_Rc2CbcDecrypt(Rc2* rc2, byte* out,
|
||||||
const byte* in, word32 sz);
|
const byte* in, word32 sz);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Reference in New Issue
Block a user