error crypt header adjusted and removed from ctaocrypt
This commit is contained in:
parent
6f17e5ecd0
commit
161a90aeae
@ -1,325 +0,0 @@
|
||||
/* error.c
|
||||
*
|
||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
const char* CTaoCryptGetErrorString(int error)
|
||||
{
|
||||
#ifdef NO_ERROR_STRINGS
|
||||
|
||||
(void)error;
|
||||
return "no support for error strings built in";
|
||||
|
||||
#else
|
||||
|
||||
switch (error) {
|
||||
|
||||
case OPEN_RAN_E :
|
||||
return "opening random device error";
|
||||
|
||||
case READ_RAN_E :
|
||||
return "reading random device error";
|
||||
|
||||
case WINCRYPT_E :
|
||||
return "windows crypt init error";
|
||||
|
||||
case CRYPTGEN_E :
|
||||
return "windows crypt generation error";
|
||||
|
||||
case RAN_BLOCK_E :
|
||||
return "random device read would block error";
|
||||
|
||||
case BAD_MUTEX_E :
|
||||
return "Bad mutex, operation failed";
|
||||
|
||||
case MP_INIT_E :
|
||||
return "mp_init error state";
|
||||
|
||||
case MP_READ_E :
|
||||
return "mp_read error state";
|
||||
|
||||
case MP_EXPTMOD_E :
|
||||
return "mp_exptmod error state";
|
||||
|
||||
case MP_TO_E :
|
||||
return "mp_to_xxx error state, can't convert";
|
||||
|
||||
case MP_SUB_E :
|
||||
return "mp_sub error state, can't subtract";
|
||||
|
||||
case MP_ADD_E :
|
||||
return "mp_add error state, can't add";
|
||||
|
||||
case MP_MUL_E :
|
||||
return "mp_mul error state, can't multiply";
|
||||
|
||||
case MP_MULMOD_E :
|
||||
return "mp_mulmod error state, can't multiply mod";
|
||||
|
||||
case MP_MOD_E :
|
||||
return "mp_mod error state, can't mod";
|
||||
|
||||
case MP_INVMOD_E :
|
||||
return "mp_invmod error state, can't inv mod";
|
||||
|
||||
case MP_CMP_E :
|
||||
return "mp_cmp error state";
|
||||
|
||||
case MP_ZERO_E :
|
||||
return "mp zero result, not expected";
|
||||
|
||||
case MEMORY_E :
|
||||
return "out of memory error";
|
||||
|
||||
case RSA_WRONG_TYPE_E :
|
||||
return "RSA wrong block type for RSA function";
|
||||
|
||||
case RSA_BUFFER_E :
|
||||
return "RSA buffer error, output too small or input too big";
|
||||
|
||||
case BUFFER_E :
|
||||
return "Buffer error, output too small or input too big";
|
||||
|
||||
case ALGO_ID_E :
|
||||
return "Setting Cert AlogID error";
|
||||
|
||||
case PUBLIC_KEY_E :
|
||||
return "Setting Cert Public Key error";
|
||||
|
||||
case DATE_E :
|
||||
return "Setting Cert Date validity error";
|
||||
|
||||
case SUBJECT_E :
|
||||
return "Setting Cert Subject name error";
|
||||
|
||||
case ISSUER_E :
|
||||
return "Setting Cert Issuer name error";
|
||||
|
||||
case CA_TRUE_E :
|
||||
return "Setting basic constraint CA true error";
|
||||
|
||||
case EXTENSIONS_E :
|
||||
return "Setting extensions error";
|
||||
|
||||
case ASN_PARSE_E :
|
||||
return "ASN parsing error, invalid input";
|
||||
|
||||
case ASN_VERSION_E :
|
||||
return "ASN version error, invalid number";
|
||||
|
||||
case ASN_GETINT_E :
|
||||
return "ASN get big int error, invalid data";
|
||||
|
||||
case ASN_RSA_KEY_E :
|
||||
return "ASN key init error, invalid input";
|
||||
|
||||
case ASN_OBJECT_ID_E :
|
||||
return "ASN object id error, invalid id";
|
||||
|
||||
case ASN_TAG_NULL_E :
|
||||
return "ASN tag error, not null";
|
||||
|
||||
case ASN_EXPECT_0_E :
|
||||
return "ASN expect error, not zero";
|
||||
|
||||
case ASN_BITSTR_E :
|
||||
return "ASN bit string error, wrong id";
|
||||
|
||||
case ASN_UNKNOWN_OID_E :
|
||||
return "ASN oid error, unknown sum id";
|
||||
|
||||
case ASN_DATE_SZ_E :
|
||||
return "ASN date error, bad size";
|
||||
|
||||
case ASN_BEFORE_DATE_E :
|
||||
return "ASN date error, current date before";
|
||||
|
||||
case ASN_AFTER_DATE_E :
|
||||
return "ASN date error, current date after";
|
||||
|
||||
case ASN_SIG_OID_E :
|
||||
return "ASN signature error, mismatched oid";
|
||||
|
||||
case ASN_TIME_E :
|
||||
return "ASN time error, unkown time type";
|
||||
|
||||
case ASN_INPUT_E :
|
||||
return "ASN input error, not enough data";
|
||||
|
||||
case ASN_SIG_CONFIRM_E :
|
||||
return "ASN sig error, confirm failure";
|
||||
|
||||
case ASN_SIG_HASH_E :
|
||||
return "ASN sig error, unsupported hash type";
|
||||
|
||||
case ASN_SIG_KEY_E :
|
||||
return "ASN sig error, unsupported key type";
|
||||
|
||||
case ASN_DH_KEY_E :
|
||||
return "ASN key init error, invalid input";
|
||||
|
||||
case ASN_NTRU_KEY_E :
|
||||
return "ASN NTRU key decode error, invalid input";
|
||||
|
||||
case ASN_CRIT_EXT_E:
|
||||
return "X.509 Critical extension ignored";
|
||||
|
||||
case ECC_BAD_ARG_E :
|
||||
return "ECC input argument wrong type, invalid input";
|
||||
|
||||
case ASN_ECC_KEY_E :
|
||||
return "ECC ASN1 bad key data, invalid input";
|
||||
|
||||
case ECC_CURVE_OID_E :
|
||||
return "ECC curve sum OID unsupported, invalid input";
|
||||
|
||||
case BAD_FUNC_ARG :
|
||||
return "Bad function argument";
|
||||
|
||||
case NOT_COMPILED_IN :
|
||||
return "Feature not compiled in";
|
||||
|
||||
case UNICODE_SIZE_E :
|
||||
return "Unicode password too big";
|
||||
|
||||
case NO_PASSWORD :
|
||||
return "No password provided by user";
|
||||
|
||||
case ALT_NAME_E :
|
||||
return "Alt Name problem, too big";
|
||||
|
||||
case AES_GCM_AUTH_E:
|
||||
return "AES-GCM Authentication check fail";
|
||||
|
||||
case AES_CCM_AUTH_E:
|
||||
return "AES-CCM Authentication check fail";
|
||||
|
||||
case CAVIUM_INIT_E:
|
||||
return "Cavium Init type error";
|
||||
|
||||
case COMPRESS_INIT_E:
|
||||
return "Compress Init error";
|
||||
|
||||
case COMPRESS_E:
|
||||
return "Compress error";
|
||||
|
||||
case DECOMPRESS_INIT_E:
|
||||
return "DeCompress Init error";
|
||||
|
||||
case DECOMPRESS_E:
|
||||
return "DeCompress error";
|
||||
|
||||
case BAD_ALIGN_E:
|
||||
return "Bad alignment error, no alloc help";
|
||||
|
||||
case ASN_NO_SIGNER_E :
|
||||
return "ASN no signer error to confirm failure";
|
||||
|
||||
case ASN_CRL_CONFIRM_E :
|
||||
return "ASN CRL sig error, confirm failure";
|
||||
|
||||
case ASN_CRL_NO_SIGNER_E :
|
||||
return "ASN CRL no signer error to confirm failure";
|
||||
|
||||
case ASN_OCSP_CONFIRM_E :
|
||||
return "ASN OCSP sig error, confirm failure";
|
||||
|
||||
case BAD_ENC_STATE_E:
|
||||
return "Bad ecc encrypt state operation";
|
||||
|
||||
case BAD_PADDING_E:
|
||||
return "Bad padding, message wrong length";
|
||||
|
||||
case REQ_ATTRIBUTE_E:
|
||||
return "Setting cert request attributes error";
|
||||
|
||||
case PKCS7_OID_E:
|
||||
return "PKCS#7 error: mismatched OID value";
|
||||
|
||||
case PKCS7_RECIP_E:
|
||||
return "PKCS#7 error: no matching recipient found";
|
||||
|
||||
case FIPS_NOT_ALLOWED_E:
|
||||
return "FIPS mode not allowed error";
|
||||
|
||||
case ASN_NAME_INVALID_E:
|
||||
return "Name Constraint error";
|
||||
|
||||
case RNG_FAILURE_E:
|
||||
return "Random Number Generator failed";
|
||||
|
||||
case HMAC_MIN_KEYLEN_E:
|
||||
return "FIPS Mode HMAC Minimum Key Length error";
|
||||
|
||||
case RSA_PAD_E:
|
||||
return "Rsa Padding error";
|
||||
|
||||
case LENGTH_ONLY_E:
|
||||
return "Output length only set, not for other use error";
|
||||
|
||||
case IN_CORE_FIPS_E:
|
||||
return "In Core Integrity check FIPS error";
|
||||
|
||||
case AES_KAT_FIPS_E:
|
||||
return "AES Known Answer Test check FIPS error";
|
||||
|
||||
case DES3_KAT_FIPS_E:
|
||||
return "DES3 Known Answer Test check FIPS error";
|
||||
|
||||
case HMAC_KAT_FIPS_E:
|
||||
return "HMAC Known Answer Test check FIPS error";
|
||||
|
||||
case RSA_KAT_FIPS_E:
|
||||
return "RSA Known Answer Test check FIPS error";
|
||||
|
||||
case DRBG_KAT_FIPS_E:
|
||||
return "DRBG Known Answer Test check FIPS error";
|
||||
|
||||
case DRBG_CONT_FIPS_E:
|
||||
return "DRBG Continuous Test FIPS error";
|
||||
|
||||
case AESGCM_KAT_FIPS_E:
|
||||
return "AESGCM Known Answer Test check FIPS error";
|
||||
|
||||
default:
|
||||
return "unknown error number";
|
||||
|
||||
}
|
||||
|
||||
#endif /* NO_ERROR_STRINGS */
|
||||
|
||||
}
|
||||
|
||||
void CTaoCryptErrorString(int error, char* buffer)
|
||||
{
|
||||
XSTRNCPY(buffer, CTaoCryptGetErrorString(error), CYASSL_MAX_ERROR_SZ);
|
||||
}
|
@ -24,137 +24,9 @@
|
||||
#define CTAO_CRYPT_ERROR_H
|
||||
|
||||
/* for name change and fips compatibility @wc_fips */
|
||||
#ifndef HAVE_FIPS
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#else
|
||||
#include <cyassl/ctaocrypt/types.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#define CTaoCryptErrorString wc_ErrorString
|
||||
#define CTaoCryptGetErrorString wc_GetErrorString
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* error codes */
|
||||
enum {
|
||||
MAX_CODE_E = -100, /* errors -101 - -299 */
|
||||
OPEN_RAN_E = -101, /* opening random device error */
|
||||
READ_RAN_E = -102, /* reading random device error */
|
||||
WINCRYPT_E = -103, /* windows crypt init error */
|
||||
CRYPTGEN_E = -104, /* windows crypt generation error */
|
||||
RAN_BLOCK_E = -105, /* reading random device would block */
|
||||
BAD_MUTEX_E = -106, /* Bad mutex operation */
|
||||
|
||||
MP_INIT_E = -110, /* mp_init error state */
|
||||
MP_READ_E = -111, /* mp_read error state */
|
||||
MP_EXPTMOD_E = -112, /* mp_exptmod error state */
|
||||
MP_TO_E = -113, /* mp_to_xxx error state, can't convert */
|
||||
MP_SUB_E = -114, /* mp_sub error state, can't subtract */
|
||||
MP_ADD_E = -115, /* mp_add error state, can't add */
|
||||
MP_MUL_E = -116, /* mp_mul error state, can't multiply */
|
||||
MP_MULMOD_E = -117, /* mp_mulmod error state, can't multiply mod */
|
||||
MP_MOD_E = -118, /* mp_mod error state, can't mod */
|
||||
MP_INVMOD_E = -119, /* mp_invmod error state, can't inv mod */
|
||||
MP_CMP_E = -120, /* mp_cmp error state */
|
||||
MP_ZERO_E = -121, /* got a mp zero result, not expected */
|
||||
|
||||
MEMORY_E = -125, /* out of memory error */
|
||||
|
||||
RSA_WRONG_TYPE_E = -130, /* RSA wrong block type for RSA function */
|
||||
RSA_BUFFER_E = -131, /* RSA buffer error, output too small or
|
||||
input too large */
|
||||
BUFFER_E = -132, /* output buffer too small or input too large */
|
||||
ALGO_ID_E = -133, /* setting algo id error */
|
||||
PUBLIC_KEY_E = -134, /* setting public key error */
|
||||
DATE_E = -135, /* setting date validity error */
|
||||
SUBJECT_E = -136, /* setting subject name error */
|
||||
ISSUER_E = -137, /* setting issuer name error */
|
||||
CA_TRUE_E = -138, /* setting CA basic constraint true error */
|
||||
EXTENSIONS_E = -139, /* setting extensions error */
|
||||
|
||||
ASN_PARSE_E = -140, /* ASN parsing error, invalid input */
|
||||
ASN_VERSION_E = -141, /* ASN version error, invalid number */
|
||||
ASN_GETINT_E = -142, /* ASN get big int error, invalid data */
|
||||
ASN_RSA_KEY_E = -143, /* ASN key init error, invalid input */
|
||||
ASN_OBJECT_ID_E = -144, /* ASN object id error, invalid id */
|
||||
ASN_TAG_NULL_E = -145, /* ASN tag error, not null */
|
||||
ASN_EXPECT_0_E = -146, /* ASN expect error, not zero */
|
||||
ASN_BITSTR_E = -147, /* ASN bit string error, wrong id */
|
||||
ASN_UNKNOWN_OID_E = -148, /* ASN oid error, unknown sum id */
|
||||
ASN_DATE_SZ_E = -149, /* ASN date error, bad size */
|
||||
ASN_BEFORE_DATE_E = -150, /* ASN date error, current date before */
|
||||
ASN_AFTER_DATE_E = -151, /* ASN date error, current date after */
|
||||
ASN_SIG_OID_E = -152, /* ASN signature error, mismatched oid */
|
||||
ASN_TIME_E = -153, /* ASN time error, unknown time type */
|
||||
ASN_INPUT_E = -154, /* ASN input error, not enough data */
|
||||
ASN_SIG_CONFIRM_E = -155, /* ASN sig error, confirm failure */
|
||||
ASN_SIG_HASH_E = -156, /* ASN sig error, unsupported hash type */
|
||||
ASN_SIG_KEY_E = -157, /* ASN sig error, unsupported key type */
|
||||
ASN_DH_KEY_E = -158, /* ASN key init error, invalid input */
|
||||
ASN_NTRU_KEY_E = -159, /* ASN ntru key decode error, invalid input */
|
||||
ASN_CRIT_EXT_E = -160, /* ASN unsupported critical extension */
|
||||
|
||||
ECC_BAD_ARG_E = -170, /* ECC input argument of wrong type */
|
||||
ASN_ECC_KEY_E = -171, /* ASN ECC bad input */
|
||||
ECC_CURVE_OID_E = -172, /* Unsupported ECC OID curve type */
|
||||
BAD_FUNC_ARG = -173, /* Bad function argument provided */
|
||||
NOT_COMPILED_IN = -174, /* Feature not compiled in */
|
||||
UNICODE_SIZE_E = -175, /* Unicode password too big */
|
||||
NO_PASSWORD = -176, /* no password provided by user */
|
||||
ALT_NAME_E = -177, /* alt name size problem, too big */
|
||||
|
||||
AES_GCM_AUTH_E = -180, /* AES-GCM Authentication check failure */
|
||||
AES_CCM_AUTH_E = -181, /* AES-CCM Authentication check failure */
|
||||
|
||||
CAVIUM_INIT_E = -182, /* Cavium Init type error */
|
||||
|
||||
COMPRESS_INIT_E = -183, /* Compress init error */
|
||||
COMPRESS_E = -184, /* Compress error */
|
||||
DECOMPRESS_INIT_E = -185, /* DeCompress init error */
|
||||
DECOMPRESS_E = -186, /* DeCompress error */
|
||||
|
||||
BAD_ALIGN_E = -187, /* Bad alignment for operation, no alloc */
|
||||
ASN_NO_SIGNER_E = -188, /* ASN no signer to confirm failure */
|
||||
ASN_CRL_CONFIRM_E = -189, /* ASN CRL signature confirm failure */
|
||||
ASN_CRL_NO_SIGNER_E = -190, /* ASN CRL no signer to confirm failure */
|
||||
ASN_OCSP_CONFIRM_E = -191, /* ASN OCSP signature confirm failure */
|
||||
|
||||
BAD_ENC_STATE_E = -192, /* Bad ecc enc state operation */
|
||||
BAD_PADDING_E = -193, /* Bad padding, msg not correct length */
|
||||
|
||||
REQ_ATTRIBUTE_E = -194, /* setting cert request attributes error */
|
||||
|
||||
PKCS7_OID_E = -195, /* PKCS#7, mismatched OID error */
|
||||
PKCS7_RECIP_E = -196, /* PKCS#7, recipient error */
|
||||
FIPS_NOT_ALLOWED_E = -197, /* FIPS not allowed error */
|
||||
ASN_NAME_INVALID_E = -198, /* ASN name constraint error */
|
||||
|
||||
RNG_FAILURE_E = -199, /* RNG Failed, Reinitialize */
|
||||
HMAC_MIN_KEYLEN_E = -200, /* FIPS Mode HMAC Minimum Key Length error */
|
||||
RSA_PAD_E = -201, /* RSA Padding Error */
|
||||
LENGTH_ONLY_E = -202, /* Returning output length only */
|
||||
|
||||
IN_CORE_FIPS_E = -203, /* In Core Integrity check failure */
|
||||
AES_KAT_FIPS_E = -204, /* AES KAT failure */
|
||||
DES3_KAT_FIPS_E = -205, /* DES3 KAT failure */
|
||||
HMAC_KAT_FIPS_E = -206, /* HMAC KAT failure */
|
||||
RSA_KAT_FIPS_E = -207, /* RSA KAT failure */
|
||||
DRBG_KAT_FIPS_E = -208, /* HASH DRBG KAT failure */
|
||||
DRBG_CONT_FIPS_E = -209, /* HASH DRBG Continious test failure */
|
||||
AESGCM_KAT_FIPS_E = -210, /* AESGCM KAT failure */
|
||||
|
||||
MIN_CODE_E = -300 /* errors -101 - -299 */
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API void CTaoCryptErrorString(int err, char* buff);
|
||||
CYASSL_API const char* CTaoCryptGetErrorString(int error);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* CTAO_CRYPT_ERROR_H */
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ if BUILD_FIPS
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
ctaocrypt/src/logging.c \
|
||||
ctaocrypt/src/wc_port.c \
|
||||
ctaocrypt/src/error.c
|
||||
wolfcrypt/src/error.c
|
||||
else
|
||||
src_libwolfssl_la_SOURCES += \
|
||||
wolfcrypt/src/logging.c \
|
||||
|
@ -25,10 +25,11 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
/* compatibility and fips @wc_fips */
|
||||
#ifndef HAVE_FIPS
|
||||
#define CTaoCryptErrorString wc_CryptErrorString
|
||||
#define CTaoCryptGetErrorString wc_CryptGetErrorString
|
||||
#ifdef HAVE_FIPS
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
#define wc_ErrorString CTaoCryptErrorString
|
||||
#define wc_GetErrorString CTaoCryptGetErrorString
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -154,11 +155,6 @@ WOLFSSL_API const char* wc_GetErrorString(int error);
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
#else
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
#define wc_ErrorString CTaoCryptErrorString
|
||||
#define wc_GetErrorString CTaoCryptGetErrorString
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* WOLF_CRYPT_ERROR_H */
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user