Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update error handling and debug logging #92

Merged
merged 11 commits into from
Jan 15, 2025
150 changes: 109 additions & 41 deletions ScosslCommon/inc/scossl_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,62 +91,129 @@ void scossl_destroy_logging();

// SCOSSL function codes
typedef enum {
// ScosslCommon
SCOSSL_ERR_F_ENUM_START= 100,
SCOSSL_ERR_F_AES_CCM_CIPHER,
SCOSSL_ERR_F_AES_CCM_CTRL,
SCOSSL_ERR_F_AES_CCM_SET_IV_FIXED,
SCOSSL_ERR_F_AES_CCM_SET_IV_LEN,
SCOSSL_ERR_F_AES_CCM_SET_TLS1_AAD,
SCOSSL_ERR_F_AES_CCM_TLS,
SCOSSL_ERR_F_AES_GCM_CTRL,
SCOSSL_ERR_F_AES_GCM_CIPHER,
SCOSSL_ERR_F_AES_GCM_IV_GEN,
SCOSSL_ERR_F_AES_GCM_SET_IV_FIXED,
SCOSSL_ERR_F_AES_GCM_SET_IV_INV,
SCOSSL_ERR_F_AES_GCM_SET_IV_LEN,
SCOSSL_ERR_F_AES_GCM_SET_TLS1_AAD,
SCOSSL_ERR_F_AES_GCM_TLS,
SCOSSL_ERR_F_AES_XTS_CIPHER,
SCOSSL_ERR_F_AES_XTS_CTRL,
SCOSSL_ERR_F_DH_COMPUTE_KEY,
SCOSSL_ERR_F_DH_GENERATE_KEY,
SCOSSL_ERR_F_DH_GENERATE_KEYPAIR,
SCOSSL_ERR_F_DH_GET_GROUP_BY_NID,
SCOSSL_ERR_F_DH_IMPORT_KEYPAIR,
SCOSSL_ERR_F_DIGESTS,
SCOSSL_ERR_F_ECC_GENERATE_KEYPAIR,
SCOSSL_ERR_F_ECC_IMPORT_KEYPAIR,
SCOSSL_ERR_F_ECC_GROUP_TO_SYMCRYPT_CURVE,
SCOS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ROV_RSA_KEYMGMT_IMPORT,
SCOSSL_ERR_F_PROV_RSA_KEYMGMT_MATCH,
SCOSSL_ERR_F_PROV_X25519_KEYMGMT_EXPORT,
SCOSSL_ERR_F_PROV_X25519_KEYMGMT_IMPORT,
SCOSSL_ERR_F_ENUM_END
} SCOSSL_ERR_FUNC;

Expand All @@ -158,6 +225,7 @@ typedef enum {
SCOSSL_ERR_R_NOT_FIPS_ALGORITHM,
SCOSSL_ERR_R_OPENSSL_FALLBACK,
SCOSSL_ERR_R_SYMCRYPT_FAILURE,
SCOSSL_ERR_R_KEYSINUSE_FAILURE,
SCOSSL_ERR_R_ENUM_END
} SCOSSL_ERR_REASON;

Expand Down
Loading