diff --git a/crypto/3des/3des-file-encrypt.c b/crypto/3des/3des-file-encrypt.c index 57109ce27..a3971f471 100644 --- a/crypto/3des/3des-file-encrypt.c +++ b/crypto/3des/3des-file-encrypt.c @@ -1,31 +1,32 @@ /* 3des-file-encrypt.c * - * Copyright (C) 2006-2014 wolfSSL Inc. - * This file is part of CyaSSL. + * Copyright (C) 2006-2015 wolfSSL Inc. * - * CyaSSL is free software; you can redistribute it and/or modify + * This file is part of wolfSSL. (formerly known as CyaSSL) + * + * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define DES3_BLOCK_SIZE 24 /* size of encryption blocks */ #define SALT_SIZE 8 @@ -37,7 +38,7 @@ int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad) { int ret; - ret = RNG_GenerateBlock(rng, salt, SALT_SIZE); + ret = wc_RNG_GenerateBlock(rng, salt, SALT_SIZE); if (ret != 0) return -1020; @@ -45,7 +46,7 @@ int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad) salt[0] = 0; /* message is padded */ /* stretches key */ - ret = PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, + ret = wc_PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, size, SHA256); if (ret != 0) return -1030; @@ -84,7 +85,7 @@ int Des3Encrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile) input = malloc(length); output = malloc(length); - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) { printf("Failed to initialize random number generator\n"); return -1030; @@ -101,7 +102,7 @@ int Des3Encrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile) input[i] = padCounter; } - ret = RNG_GenerateBlock(&rng, iv, DES3_BLOCK_SIZE); + ret = wc_RNG_GenerateBlock(&rng, iv, DES3_BLOCK_SIZE); if (ret != 0) return -1020; @@ -111,12 +112,12 @@ int Des3Encrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile) return -1040; /* sets key */ - ret = Des3_SetKey(des3, key, iv, DES_ENCRYPTION); + ret = wc_Des3_SetKey(des3, key, iv, DES_ENCRYPTION); if (ret != 0) return -1001; /* encrypts the message to the ouput based on input length + padding */ - ret = Des3_CbcEncrypt(des3, output, input, length); + ret = wc_Des3_CbcEncrypt(des3, output, input, length); if (ret != 0) return -1005; @@ -162,7 +163,7 @@ int Des3Decrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile) input = malloc(aSize); output = malloc(aSize); - InitRng(&rng); + wc_InitRng(&rng); /* reads from inFile and wrties whatever is there to the input array */ ret = fread(input, 1, length, inFile); @@ -180,13 +181,13 @@ int Des3Decrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile) } /* replicates old key if keys match */ - ret = PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, + ret = wc_PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, size, SHA256); if (ret != 0) return -1050; /* sets key */ - ret = Des3_SetKey(des3, key, iv, DES_DECRYPTION); + ret = wc_Des3_SetKey(des3, key, iv, DES_DECRYPTION); if (ret != 0) return -1002; @@ -197,7 +198,7 @@ int Des3Decrypt(Des3* des3, byte* key, int size, FILE* inFile, FILE* outFile) input[i] = input[i + (DES3_BLOCK_SIZE + SALT_SIZE)]; } /* decrypts the message to output based on input length + padding */ - ret = Des3_CbcDecrypt(des3, output, input, length); + ret = wc_Des3_CbcDecrypt(des3, output, input, length); if (ret != 0) return -1006; diff --git a/crypto/aes/aes-file-encrypt.c b/crypto/aes/aes-file-encrypt.c index 0a8aa3e24..81f7e30a9 100644 --- a/crypto/aes/aes-file-encrypt.c +++ b/crypto/aes/aes-file-encrypt.c @@ -1,31 +1,32 @@ /* aes-file-encrypt.c * - * Copyright (C) 2006-2014 wolfSSL Inc. - * This file is part of CyaSSL. + * Copyright (C) 2006-2015 wolfSSL Inc. * - * CyaSSL is free software; you can redistribute it and/or modify + * This file is part of wolfSSL. (formerly known as CyaSSL) + * + * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define SALT_SIZE 8 @@ -36,7 +37,7 @@ int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad) { int ret; - ret = RNG_GenerateBlock(rng, salt, SALT_SIZE); + ret = wc_RNG_GenerateBlock(rng, salt, SALT_SIZE); if (ret != 0) return -1020; @@ -44,7 +45,7 @@ int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad) salt[0] = 0; /* stretches key */ - ret = PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, + ret = wc_PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, size, SHA256); if (ret != 0) return -1030; @@ -83,7 +84,7 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile) input = malloc(length); output = malloc(length); - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) { printf("Failed to initialize random number generator\n"); return -1030; @@ -100,7 +101,7 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile) input[i] = padCounter; } - ret = RNG_GenerateBlock(&rng, iv, AES_BLOCK_SIZE); + ret = wc_RNG_GenerateBlock(&rng, iv, AES_BLOCK_SIZE); if (ret != 0) return -1020; @@ -110,12 +111,12 @@ int AesEncrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile) return -1040; /* sets key */ - ret = AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION); + ret = wc_AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION); if (ret != 0) return -1001; /* encrypts the message to the ouput based on input length + padding */ - ret = AesCbcEncrypt(aes, output, input, length); + ret = wc_AesCbcEncrypt(aes, output, input, length); if (ret != 0) return -1005; @@ -161,7 +162,7 @@ int AesDecrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile) input = malloc(aSize); output = malloc(aSize); - InitRng(&rng); + wc_InitRng(&rng); /* reads from inFile and wrties whatever is there to the input array */ ret = fread(input, 1, length, inFile); @@ -179,13 +180,13 @@ int AesDecrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile) } /* replicates old key if keys match */ - ret = PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, + ret = wc_PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, size, SHA256); if (ret != 0) return -1050; /* sets key */ - ret = AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_DECRYPTION); + ret = wc_AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_DECRYPTION); if (ret != 0) return -1002; @@ -196,7 +197,7 @@ int AesDecrypt(Aes* aes, byte* key, int size, FILE* inFile, FILE* outFile) input[i] = input[i + (AES_BLOCK_SIZE + SALT_SIZE)]; } /* decrypts the message to output based on input length + padding*/ - ret = AesCbcDecrypt(aes, output, input, length); + ret = wc_AesCbcDecrypt(aes, output, input, length); if (ret != 0) return -1006; diff --git a/crypto/camellia/camellia-encrypt.c b/crypto/camellia/camellia-encrypt.c index 16c1e3530..334faf69c 100644 --- a/crypto/camellia/camellia-encrypt.c +++ b/crypto/camellia/camellia-encrypt.c @@ -1,31 +1,32 @@ /* camellia-encrypt.c * - * Copyright (C) 2006-2014 wolfSSL Inc. - * This file is part of CyaSSL. + * Copyright (C) 2006-2015 wolfSSL Inc. * - * CyaSSL is free software; you can redistribute it and/or modify + * This file is part of wolfSSL. (formerly known as CyaSSL) + * + * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define SALT_SIZE 8 @@ -36,7 +37,7 @@ int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad) { int ret; - ret = RNG_GenerateBlock(rng, salt, SALT_SIZE-1); + ret = wc_RNG_GenerateBlock(rng, salt, SALT_SIZE-1); if (ret != 0) return -1020; @@ -44,7 +45,7 @@ int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad) salt[0] = 0; /* message is padded */ /* stretches key */ - ret = PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, + ret = wc_PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, size, SHA256); if (ret != 0) return -1030; @@ -84,7 +85,7 @@ int CamelliaEncrypt(Camellia* cam, byte* key, int size, FILE* inFile, input = malloc(length); output = malloc(length); - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) { printf("Failed to initialize random number generator\n"); return -1030; @@ -101,7 +102,7 @@ int CamelliaEncrypt(Camellia* cam, byte* key, int size, FILE* inFile, input[i] = padCounter; } - ret = RNG_GenerateBlock(&rng, iv, CAMELLIA_BLOCK_SIZE); + ret = wc_RNG_GenerateBlock(&rng, iv, CAMELLIA_BLOCK_SIZE); if (ret != 0) return -1020; @@ -111,12 +112,12 @@ int CamelliaEncrypt(Camellia* cam, byte* key, int size, FILE* inFile, return -1040; /* sets key */ - ret = CamelliaSetKey(cam, key, CAMELLIA_BLOCK_SIZE, iv); + ret = wc_CamelliaSetKey(cam, key, CAMELLIA_BLOCK_SIZE, iv); if (ret != 0) return -1001; /* encrypts the message to the ouput based on input length + padding */ - CamelliaCbcEncrypt(cam, output, input, length); + wc_CamelliaCbcEncrypt(cam, output, input, length); /* writes to outFile */ fwrite(salt, 1, SALT_SIZE, outFile); @@ -161,7 +162,7 @@ int CamelliaDecrypt(Camellia* cam, byte* key, int size, FILE* inFile, input = malloc(aSize); output = malloc(aSize); - InitRng(&rng); + wc_InitRng(&rng); /* reads from inFile and wrties whatever is there to the input array */ ret = fread(input, 1, length, inFile); @@ -179,13 +180,13 @@ int CamelliaDecrypt(Camellia* cam, byte* key, int size, FILE* inFile, } /* replicates old key if keys match */ - ret = PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, + ret = wc_PBKDF2(key, key, strlen((const char*)key), salt, SALT_SIZE, 4096, size, SHA256); if (ret != 0) return -1050; /* sets key */ - ret = CamelliaSetKey(cam, key, CAMELLIA_BLOCK_SIZE, iv); + ret = wc_CamelliaSetKey(cam, key, CAMELLIA_BLOCK_SIZE, iv); if (ret != 0) return -1002; @@ -196,7 +197,7 @@ int CamelliaDecrypt(Camellia* cam, byte* key, int size, FILE* inFile, input[i] = input[i + (CAMELLIA_BLOCK_SIZE + SALT_SIZE)]; } /* decrypts the message to output based on input length + padding */ - CamelliaCbcDecrypt(cam, output, input, length); + wc_CamelliaCbcDecrypt(cam, output, input, length); if (salt[0] != 0) { /* reduces length based on number of padded elements */