diff options
Diffstat (limited to 'src/openssl/bn.c')
-rw-r--r-- | src/openssl/bn.c | 65 |
1 files changed, 24 insertions, 41 deletions
diff --git a/src/openssl/bn.c b/src/openssl/bn.c index db186d11..f0f5eb45 100644 --- a/src/openssl/bn.c +++ b/src/openssl/bn.c @@ -1,21 +1,29 @@ -/** - * XMLSec library +/* + * XML Security Library (http://www.aleksey.com/xmlsec). * - * Reading/writing BIGNUM values * * This is free software; see Copyright file in the source * distribution for preciese wording. * * Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved. */ +/** + * SECTION:bn + * @Short_description: Big numbers (BIGNUM) support functions implementation for OpenSSL. + * @Stability: Stable + * + */ + #include "globals.h" #include <stdlib.h> #include <string.h> +#include <openssl/bn.h> #include <libxml/tree.h> #include <xmlsec/xmlsec.h> +#include <xmlsec/xmltree.h> #include <xmlsec/buffer.h> #include <xmlsec/base64.h> #include <xmlsec/errors.h> @@ -25,7 +33,7 @@ /** * xmlSecOpenSSLNodeGetBNValue: - * @cur: the poitner to an XML node. + * @cur: the pointer to an XML node. * @a: the BIGNUM buffer. * * Converts the node content from CryptoBinary format @@ -45,32 +53,21 @@ xmlSecOpenSSLNodeGetBNValue(const xmlNodePtr cur, BIGNUM **a) { ret = xmlSecBufferInitialize(&buf, 128); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecBufferInitialize", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecInternalError("xmlSecBufferInitialize", NULL); return(NULL); } ret = xmlSecBufferBase64NodeContentRead(&buf, cur); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecBufferBase64NodeContentRead", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecInternalError("xmlSecBufferBase64NodeContentRead", NULL); xmlSecBufferFinalize(&buf); return(NULL); } (*a) = BN_bin2bn(xmlSecBufferGetData(&buf), xmlSecBufferGetSize(&buf), (*a)); if( (*a) == NULL) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "BN_bin2bn", - XMLSEC_ERRORS_R_CRYPTO_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecOpenSSLError2("BN_bin2bn", NULL, + "size=%lu", (unsigned long)(xmlSecBufferGetSize(&buf))); xmlSecBufferFinalize(&buf); return(NULL); } @@ -105,21 +102,14 @@ xmlSecOpenSSLNodeSetBNValue(xmlNodePtr cur, const BIGNUM *a, int addLineBreaks) ret = xmlSecBufferInitialize(&buf, BN_num_bytes(a) + 1); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecBufferInitialize", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - "size=%d", BN_num_bytes(a) + 1); + xmlSecInternalError2("xmlSecBufferInitialize", NULL, + "size=%d", BN_num_bytes(a) + 1); return(-1); } ret = BN_bn2bin(a, xmlSecBufferGetData(&buf)); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "BN_bn2bin", - XMLSEC_ERRORS_R_CRYPTO_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecOpenSSLError("BN_bn2bin", NULL); xmlSecBufferFinalize(&buf); return(-1); } @@ -127,34 +117,27 @@ xmlSecOpenSSLNodeSetBNValue(xmlNodePtr cur, const BIGNUM *a, int addLineBreaks) ret = xmlSecBufferSetSize(&buf, size); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecBufferSetSize", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - "size=%d", size); + xmlSecInternalError2("xmlSecBufferSetSize", NULL, + "size=%d", size); xmlSecBufferFinalize(&buf); return(-1); } if(addLineBreaks) { - xmlNodeSetContent(cur, xmlSecStringCR); + xmlNodeSetContent(cur, xmlSecGetDefaultLineFeed()); } else { xmlNodeSetContent(cur, xmlSecStringEmpty); } ret = xmlSecBufferBase64NodeContentWrite(&buf, cur, xmlSecBase64GetDefaultLineSize()); if(ret < 0) { - xmlSecError(XMLSEC_ERRORS_HERE, - NULL, - "xmlSecBufferBase64NodeContentWrite", - XMLSEC_ERRORS_R_XMLSEC_FAILED, - XMLSEC_ERRORS_NO_MESSAGE); + xmlSecInternalError("xmlSecBufferBase64NodeContentWrite", NULL); xmlSecBufferFinalize(&buf); return(-1); } if(addLineBreaks) { - xmlNodeAddContent(cur, xmlSecStringCR); + xmlNodeAddContent(cur, xmlSecGetDefaultLineFeed()); } xmlSecBufferFinalize(&buf); |