header files for aes, arc4, camellia, chacha, dh, and dsa

This commit is contained in:
Jacob Barthelmeh
2014-12-18 11:44:48 -07:00
parent d7a3585a96
commit 607760f829
6 changed files with 153 additions and 80 deletions

View File

@ -2,14 +2,14 @@
*
* 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
* 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.
@ -26,81 +26,83 @@
#define WOLF_CRYPT_AES_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
/* included for fips*/
#include <cyassl/ctaocrypt/aes.h>
#ifdef __cplusplus
extern "C" {
#endif
CYASSL_API int wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
WOLFSSL_API int wc_AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
int dir);
CYASSL_API int wc_AesSetIV(Aes* aes, const byte* iv);
CYASSL_API int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
CYASSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
CYASSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
WOLFSSL_API int wc_AesSetIV(Aes* aes, const byte* iv);
WOLFSSL_API int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
WOLFSSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
const byte* key, word32 keySz, const byte* iv);
/* AES-CTR */
#ifdef CYASSL_AES_COUNTER
CYASSL_API void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
WOLFSSL_API void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
#endif
/* AES-DIRECT */
#if defined(CYASSL_AES_DIRECT)
CYASSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
CYASSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
CYASSL_API int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
WOLFSSL_API int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
const byte* iv, int dir);
#endif
#ifdef HAVE_AESGCM
CYASSL_API int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
CYASSL_API int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
WOLFSSL_API int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
WOLFSSL_API int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
WOLFSSL_API int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
CYASSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
const byte* authIn, word32 authInSz,
byte* authTag, word32 authTagSz);
#endif /* HAVE_AESGCM */
#ifdef HAVE_AESCCM
CYASSL_APT void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
CYASSL_API void wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
WOLFSSL_API void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
WOLFSSL_API void wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
const byte* nonce, word32 nonceSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
WOLFSSL_API int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
const byte* nonce, word32 nonceSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
#endif /* HAVE_AESCCM */
#ifdef HAVE_CAVIUM
CYASSL_API int wc_AesInitCavium(Aes*, int);
CYASSL_API void wc_AesFreeCavium(Aes*);
WOLFSSL_API int wc_AesInitCavium(Aes*, int);
WOLFSSL_API void wc_AesFreeCavium(Aes*);
#endif
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int wc_AesSetKey_fips(Aes* aes, const byte* key, word32 len,
WOLFSSL_API int wc_AesSetKey_fips(Aes* aes, const byte* key, word32 len,
const byte* iv, int dir);
CYASSL_API int wc_AesSetIV_fips(Aes* aes, const byte* iv);
CYASSL_API int wc_AesCbcEncrypt_fips(Aes* aes, byte* out, const byte* in,
WOLFSSL_API int wc_AesSetIV_fips(Aes* aes, const byte* iv);
WOLFSSL_API int wc_AesCbcEncrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz);
CYASSL_API int wc_AesCbcDecrypt_fips(Aes* aes, byte* out, const byte* in,
WOLFSSL_API int wc_AesCbcDecrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz);
CYASSL_API int wc_AesGcmSetKey_fips(Aes* aes, const byte* key, word32 len);
CYASSL_API int wc_AesGcmEncrypt_fips(Aes* aes, byte* out, const byte* in,
WOLFSSL_API int wc_AesGcmSetKey_fips(Aes* aes, const byte* key, word32 len);
WOLFSSL_API int wc_AesGcmEncrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz, const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int wc_AesGcmDecrypt_fips(Aes* aes, byte* out, const byte* in,
WOLFSSL_API int wc_AesGcmDecrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz, const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);

View File

@ -24,7 +24,7 @@
#define WOLF_CRYPT_ARC4_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
@ -51,12 +51,12 @@ typedef struct Arc4 {
#endif
} Arc4;
CYASSL_API void wc_Arc4Process(Arc4*, byte*, const byte*, word32);
CYASSL_API void wc_Arc4SetKey(Arc4*, const byte*, word32);
WOLFSSL_API void wc_Arc4Process(Arc4*, byte*, const byte*, word32);
WOLFSSL_API void wc_Arc4SetKey(Arc4*, const byte*, word32);
#ifdef HAVE_CAVIUM
CYASSL_API int wc_Arc4InitCavium(Arc4*, int);
CYASSL_API void wc_Arc4FreeCavium(Arc4*);
WOLFSSL_API int wc_Arc4InitCavium(Arc4*, int);
WOLFSSL_API void wc_Arc4FreeCavium(Arc4*);
#endif
#ifdef __cplusplus

View File

@ -1,15 +1,42 @@
/* camellia.h ver 1.2.0
*
* Copyright (c) 2006,2007
* NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer as
* the first lines of this file unmodified.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* camellia.h
*
* 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
* 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.
@ -19,9 +46,53 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CTAO_CRYPT_CAMELLIA_H
#define CTAO_CRYPT_CAMELLIA_H
#ifdef HAVE_CAMELLIA
#include <wolfssl/wolfcrypt/camellia.h>
#ifndef WOLF_CRYPT_CAMELLIA_H
#define WOLF_CRYPT_CAMELLIA_H
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
CAMELLIA_BLOCK_SIZE = 16
};
#define CAMELLIA_TABLE_BYTE_LEN 272
#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
typedef word32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
typedef struct Camellia {
word32 keySz;
KEY_TABLE_TYPE key;
word32 reg[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
word32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
} Camellia;
WOLFSSL_API int wc_CamelliaSetKey(Camellia* cam,
const byte* key, word32 len, const byte* iv);
WOLFSSL_API int wc_CamelliaSetIV(Camellia* cam, const byte* iv);
WOLFSSL_API void wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
const byte* in);
WOLFSSL_API void wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
const byte* in);
WOLFSSL_API void wc_CamelliaCbcEncrypt(Camellia* cam,
byte* out, const byte* in, word32 sz);
WOLFSSL_API void wc_CamelliaCbcDecrypt(Camellia* cam,
byte* out, const byte* in, word32 sz);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* WOLF_CRYPT_CAMELLIA_H */
#endif /* HAVE_CAMELLIA */

View File

@ -2,14 +2,14 @@
*
* 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
* 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.
@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CTAO_CRYPT_CHACHA_H
#define CTAO_CRYPT_CHACHA_H
#ifndef WOLF_CRYPT_CHACHA_H
#define WOLF_CRYPT_CHACHA_H
#include "types.h"
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
extern "C" {
@ -37,15 +37,15 @@ typedef struct ChaCha {
word32 X[16]; /* state of cipher */
} ChaCha;
CYASSL_API int Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain,
WOLFSSL_API int wc_Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain,
word32 msglen);
CYASSL_API int Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz);
WOLFSSL_API int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz);
/**
* IV(nonce) changes with each record
* counter is for what value the block counter should start ... usually 0
*/
CYASSL_API int Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter);
WOLFSSL_API int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter);
#ifdef __cplusplus
} /* extern "C" */

View File

@ -2,14 +2,14 @@
*
* 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
* 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.
@ -22,12 +22,12 @@
#ifndef NO_DH
#ifndef CTAO_CRYPT_DH_H
#define CTAO_CRYPT_DH_H
#ifndef WOLF_CRYPT_DH_H
#define WOLF_CRYPT_DH_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/integer.h>
#include <cyassl/ctaocrypt/random.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/integer.h>
#include <wolfssl/wolfcrypt/random.h>
#ifdef __cplusplus
extern "C" {
@ -40,20 +40,20 @@ typedef struct DhKey {
} DhKey;
CYASSL_API void InitDhKey(DhKey* key);
CYASSL_API void FreeDhKey(DhKey* key);
WOLFSSL_API void wc_InitDhKey(DhKey* key);
WOLFSSL_API void wc_FreeDhKey(DhKey* key);
CYASSL_API int DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv,
WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv,
word32* privSz, byte* pub, word32* pubSz);
CYASSL_API int DhAgree(DhKey* key, byte* agree, word32* agreeSz,
WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
const byte* priv, word32 privSz, const byte* otherPub,
word32 pubSz);
CYASSL_API int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
word32);
CYASSL_API int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
word32 gSz);
CYASSL_API int DhParamsLoad(const byte* input, word32 inSz, byte* p,
WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
word32* pInOutSz, byte* g, word32* gInOutSz);
@ -61,7 +61,7 @@ CYASSL_API int DhParamsLoad(const byte* input, word32 inSz, byte* p,
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_DH_H */
#endif /* WOLF_CRYPT_DH_H */
#endif /* NO_DH */

View File

@ -2,14 +2,14 @@
*
* 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
* 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.
@ -22,12 +22,12 @@
#ifndef NO_DSA
#ifndef CTAO_CRYPT_DSA_H
#define CTAO_CRYPT_DSA_H
#ifndef WOLF_CRYPT_DSA_H
#define WOLF_CRYPT_DSA_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/integer.h>
#include <cyassl/ctaocrypt/random.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/integer.h>
#include <wolfssl/wolfcrypt/random.h>
#ifdef __cplusplus
extern "C" {
@ -46,16 +46,16 @@ typedef struct DsaKey {
} DsaKey;
CYASSL_API void InitDsaKey(DsaKey* key);
CYASSL_API void FreeDsaKey(DsaKey* key);
WOLFSSL_API void wc_InitDsaKey(DsaKey* key);
WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
CYASSL_API int DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng);
CYASSL_API int DsaVerify(const byte* digest, const byte* sig, DsaKey* key,
WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng);
WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig, DsaKey* key,
int* answer);
CYASSL_API int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
word32);
CYASSL_API int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
word32);
#ifdef __cplusplus