Repository navigation
API XMLSec Core Bn
API Group: xmlsec_core_bn
Big-number (arbitrary-precision integer) utility functions.
Big numbers support functions.
Values are always treated as unsigned magnitudes; operations that would produce a result below zero return an error.
typedef xmlSecBuffer xmlSecBn;Source: include/xmlsec/bn.h
Big Number (arbitrary-precision integer).
typedef xmlSecBn* xmlSecBnPtr;Source: include/xmlsec/bn.h
Pointer to xmlSecBn.
Source: include/xmlsec/bn.h
The big number formats.
| Value | Initializer | Description |
|---|---|---|
xmlSecBnBase64 |
`` | the base64 encoded node content. |
xmlSecBnHex |
`` | the hex number. |
xmlSecBnDec |
`` | the decimal number. |
xmlSecBnPtr xmlSecBnCreate(xmlSecSize size);Source: include/xmlsec/bn.h
Creates a new BN object.
Creates a new BN object. Caller is responsible for destroying it by calling xmlSecBnDestroy function.
Parameters:
-
size— the initial allocated BN size.
Returns: the new BN or a NULL if an error occurs.
void xmlSecBnDestroy(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Destroys bn object.
Destroys bn object created with xmlSecBnCreate function.
Parameters:
-
bn— the pointer to BN.
int xmlSecBnInitialize(xmlSecBnPtr bn, xmlSecSize size);Source: include/xmlsec/bn.h
Initializes a BN object.
Initializes a BN object. Caller is responsible for destroying it by calling xmlSecBnFinalize function.
Parameters:
-
bn— the pointer to BN. -
size— the initial allocated BN size.
Returns: 0 on success or a negative value if an error occurs.
void xmlSecBnFinalize(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Destroys bn object.
Destroys bn object created with xmlSecBnInitialize function.
Parameters:
-
bn— the pointer to BN.
xmlSecByte * xmlSecBnGetData(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Gets pointer to the binary bn representation.
Parameters:
-
bn— the pointer to BN.
Returns: pointer to binary BN data or NULL if an error occurs.
int xmlSecBnSetData(xmlSecBnPtr bn, const xmlSecByte *data, xmlSecSize size);Source: include/xmlsec/bn.h
Sets the value of bn to data.
Parameters:
-
bn— the pointer to BN. -
data— the pointer to new BN binary data. -
size— the size of new BN data.
Returns: 0 on success or a negative value if an error occurs.
xmlSecSize xmlSecBnGetSize(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Gets the size of binary data in bn.
Parameters:
-
bn— the pointer to BN.
Returns: the size of binary data.
void xmlSecBnZero(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Sets the value of bn to zero.
Parameters:
-
bn— the pointer to BN.
int xmlSecBnFromString(xmlSecBnPtr bn, const xmlChar *str, xmlSecSize base);Source: include/xmlsec/bn.h
Reads bn from string str in given base.
Reads bn from string str assuming it has base base. The value is always treated as an unsigned magnitude; a sign character ('+' or '-') is not allowed and will be rejected as an invalid digit. The input string length is hard-limited to XMLSEC_BN_FROM_STRING_MAX_LEN characters (64 by default); a longer string is rejected with an error.
Parameters:
-
bn— the pointer to BN. -
str— the string with BN. -
base— the base forstr.
Returns: 0 on success or a negative value if an error occurs.
xmlChar * xmlSecBnToString(xmlSecBnPtr bn, xmlSecSize base);Source: include/xmlsec/bn.h
Writes bn to string with given base.
Writes bn to string with base base. The value is always treated as an unsigned magnitude, so the result never carries a sign. Caller is responsible for freeing returned string with xmlFree.
Parameters:
-
bn— the pointer to BN. -
base— the base for returned string.
Returns: the string representation of BN or a NULL if an error occurs.
int xmlSecBnFromHexString(xmlSecBnPtr bn, const xmlChar *str);Source: include/xmlsec/bn.h
Reads bn from hex string str.
Parameters:
-
bn— the pointer to BN. -
str— the string with BN.
Returns: 0 on success or a negative value if an error occurs.
xmlChar * xmlSecBnToHexString(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Writes bn to hex string.
Writes bn to hex string. Caller is responsible for freeing returned string with xmlFree.
Parameters:
-
bn— the pointer to BN.
Returns: the string representation of BN or a NULL if an error occurs.
int xmlSecBnFromDecString(xmlSecBnPtr bn, const xmlChar *str);Source: include/xmlsec/bn.h
Reads bn from decimal string str.
Parameters:
-
bn— the pointer to BN. -
str— the string with BN.
Returns: 0 on success or a negative value if an error occurs.
xmlChar * xmlSecBnToDecString(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Writes bn to decimal string.
Writes bn to decimal string. Caller is responsible for freeing returned string with xmlFree.
Parameters:
-
bn— the pointer to BN.
Returns: the string representation of BN or a NULL if an error occurs.
int xmlSecBnMul(xmlSecBnPtr bn, int multiplier);Source: include/xmlsec/bn.h
Multiplies bn with multiplier.
multiplier must be a positive value.
Parameters:
-
bn— the pointer to BN. -
multiplier— the multiplier.
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnDiv(xmlSecBnPtr bn, int divider, int *mod);Source: include/xmlsec/bn.h
Divides bn by divider.
Divides bn by divider and places modulus into mod. divider must be a positive value.
Parameters:
-
bn— the pointer to BN. -
divider— the divider -
mod— the pointer for modulus result.
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnAdd(xmlSecBnPtr bn, int delta);Source: include/xmlsec/bn.h
Adds delta to bn.
The value is treated as an unsigned magnitude. A negative delta performs a subtraction; if the result would go below zero an error is returned. On error, the value of bn is undefined and must not be used.
Parameters:
-
bn— the pointer to BN. -
delta— the delta.
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnReverse(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Reverses bytes order in bn.
Parameters:
-
bn— the pointer to BN.
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnPrependZeroIfMsbSet(xmlSecBnPtr bn);Source: include/xmlsec/bn.h
Prepends a 0x00 byte to bn if the most significant bit of the first byte is set.
Makes the buffer a valid DER/ASN.1 INTEGER encoding of a non-negative value. If the most significant bit is not set (or the buffer is empty), the buffer is left unchanged.
Parameters:
-
bn— the pointer to BN.
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnCompare(xmlSecBnPtr bn, const xmlSecByte *data, xmlSecSize dataSize);Source: include/xmlsec/bn.h
Compares the bn with data.
Parameters:
-
bn— the pointer to BN. -
data— the data to compare BN to. -
dataSize— thedatasize.
Returns: 0 if data is equal, negative value if bn is less or positive value if bn is greater than data.
int xmlSecBnCompareReverse(xmlSecBnPtr bn, const xmlSecByte *data, xmlSecSize dataSize);Source: include/xmlsec/bn.h
Compares the bn with reverse data.
Parameters:
-
bn— the pointer to BN. -
data— the data to compare BN to. -
dataSize— thedatasize.
Returns: 0 if data is equal, negative value if bn is less or positive value if bn is greater than data.
int xmlSecBnGetNodeValue(xmlSecBnPtr bn, xmlNodePtr cur, xmlSecBnFormat format, int reverse);Source: include/xmlsec/bn.h
Converts node content to BN value.
Converts the node content from format to bn.
Parameters:
-
bn— the pointer to BN. -
cur— the pointer to an XML node. -
format— the BN format. -
reverse— if set then reverse read buffer after reading.
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnSetNodeValue(xmlSecBnPtr bn, xmlNodePtr cur, xmlSecBnFormat format, int reverse, int addLineBreaks);Source: include/xmlsec/bn.h
Converts the bn and sets it to node content.
Parameters:
-
bn— the pointer to BN. -
cur— the pointer to an XML node. -
format— the BN format. -
reverse— the flag that indicates if to reverse the buffer before writing. -
addLineBreaks— the flag; if it is equal to 1 then linebreaks will be added before and after new buffer content. Note: ifreverseis non-zero the buffer is reversed in place before it is written; if a later step fails the BN is left reversed (the reversal is not undone on the error path).
Returns: 0 on success or a negative value if an error occurs.
int xmlSecBnBlobSetNodeValue(const xmlSecByte *data, xmlSecSize dataSize, xmlNodePtr cur, xmlSecBnFormat format, int reverse, int addLineBreaks);Source: include/xmlsec/bn.h
Converts the blob and sets it to node content.
Parameters:
-
data— the pointer to BN blob. -
dataSize— the size of BN blob. -
cur— the pointer to an XML node. -
format— the BN format. -
reverse— the flag that indicates if to reverse the buffer before writing. -
addLineBreaks— if the flag is equal to 1 then linebreaks will be added before and after new buffer content.
Returns: 0 on success or a negative value if an error occurs.