xmlsecurityengine/xmlsec/inc/xmlsec_bn.h
changeset 0 e35f40988205
child 24 74f0b3eb154c
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 /** 
       
     2  * XML Security Library (http://www.aleksey.com/xmlsec).
       
     3  *
       
     4  * Simple Big Numbers processing.
       
     5  *
       
     6  * This is free software; see Copyright file in the source
       
     7  * distribution for preciese wording.
       
     8  * 
       
     9  * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com>
       
    10  * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
       
    11  */
       
    12 #ifndef __XMLSEC_BN_H__
       
    13 #define __XMLSEC_BN_H__    
       
    14 
       
    15 #ifdef __cplusplus
       
    16 extern "C" {
       
    17 #endif /* __cplusplus */ 
       
    18 
       
    19 #include <libxml2_tree.h>
       
    20 #include "xmlsec_config.h"
       
    21 #include "xmlsec_xmlsec.h"
       
    22 #include "xmlsec_buffer.h"
       
    23 
       
    24 typedef xmlSecBuffer						xmlSecBn,
       
    25 								*xmlSecBnPtr;
       
    26 
       
    27 /**
       
    28  * xmlSecBnFormat:
       
    29  * @xmlSecBnBase64:		the base64 decoded binary blob.
       
    30  * @xmlSecBnHex:		the hex number.
       
    31  * @xmlSecBnDec:		the decimal number.
       
    32  *
       
    33  * The big numbers formats.
       
    34  */
       
    35 typedef enum {
       
    36     xmlSecBnBase64,
       
    37     xmlSecBnHex,
       
    38     xmlSecBnDec
       
    39 } xmlSecBnFormat;
       
    40 
       
    41 XMLSEC_EXPORT xmlSecBnPtr	xmlSecBnCreate			(xmlSecSize size);
       
    42 XMLSEC_EXPORT void		xmlSecBnDestroy			(xmlSecBnPtr bn);
       
    43 XMLSEC_EXPORT int		xmlSecBnInitialize		(xmlSecBnPtr bn,
       
    44 								 xmlSecSize size);
       
    45 XMLSEC_EXPORT void		xmlSecBnFinalize		(xmlSecBnPtr bn);
       
    46 XMLSEC_EXPORT xmlSecByte*	xmlSecBnGetData			(xmlSecBnPtr bn);
       
    47 XMLSEC_EXPORT int		xmlSecBnSetData			(xmlSecBnPtr bn,
       
    48 								 const xmlSecByte* data,
       
    49 								 xmlSecSize size);
       
    50 XMLSEC_EXPORT xmlSecSize	xmlSecBnGetSize			(xmlSecBnPtr bn);
       
    51 XMLSEC_EXPORT void		xmlSecBnZero			(xmlSecBnPtr bn);
       
    52 
       
    53 XMLSEC_EXPORT int		xmlSecBnFromString		(xmlSecBnPtr bn,
       
    54 								 const xmlChar* str,
       
    55 								 xmlSecSize base);
       
    56 XMLSEC_EXPORT xmlChar*		xmlSecBnToString		(xmlSecBnPtr bn,
       
    57 								 xmlSecSize base);
       
    58 XMLSEC_EXPORT int		xmlSecBnFromHexString		(xmlSecBnPtr bn,
       
    59 								 const xmlChar* str);
       
    60 XMLSEC_EXPORT xmlChar*		xmlSecBnToHexString		(xmlSecBnPtr bn);
       
    61 
       
    62 XMLSEC_EXPORT int		xmlSecBnFromDecString		(xmlSecBnPtr bn,
       
    63 								 const xmlChar* str);
       
    64 XMLSEC_EXPORT xmlChar*		xmlSecBnToDecString		(xmlSecBnPtr bn);
       
    65 
       
    66 XMLSEC_EXPORT int		xmlSecBnMul			(xmlSecBnPtr bn,
       
    67 								 int multiplier);
       
    68 XMLSEC_EXPORT int		xmlSecBnDiv			(xmlSecBnPtr bn,
       
    69 								 int divider,
       
    70 								 int* mod);
       
    71 XMLSEC_EXPORT int		xmlSecBnAdd			(xmlSecBnPtr bn, 
       
    72 								 int delta); 
       
    73 XMLSEC_EXPORT int		xmlSecBnReverse			(xmlSecBnPtr bn);
       
    74 XMLSEC_EXPORT int		xmlSecBnCompare			(xmlSecBnPtr bn,
       
    75 								 const xmlSecByte* data,
       
    76 								 xmlSecSize dataSize);
       
    77 XMLSEC_EXPORT int		xmlSecBnCompareReverse		(xmlSecBnPtr bn,
       
    78 								 const xmlSecByte* data,
       
    79 								 xmlSecSize dataSize);
       
    80 XMLSEC_EXPORT int		xmlSecBnGetNodeValue		(xmlSecBnPtr bn, 
       
    81 								 xmlNodePtr cur,
       
    82 								 xmlSecBnFormat format,
       
    83 								 int reverse);
       
    84 XMLSEC_EXPORT int 		xmlSecBnSetNodeValue		(xmlSecBnPtr bn, 
       
    85 								 xmlNodePtr cur, 
       
    86 								 xmlSecBnFormat format,
       
    87 								 int reverse,
       
    88 								 int addLineBreaks);
       
    89 XMLSEC_EXPORT int 		xmlSecBnBlobSetNodeValue	(const xmlSecByte* data,
       
    90 								 xmlSecSize dataSize,
       
    91 								 xmlNodePtr cur, 
       
    92 								 xmlSecBnFormat format,
       
    93 								 int reverse,
       
    94 								 int addLineBreaks);
       
    95 
       
    96 #ifdef __cplusplus
       
    97 }
       
    98 #endif /* __cplusplus */
       
    99 
       
   100 #endif /* __XMLSEC_BN_H__ */
       
   101