close Warning: Can't use blame annotator:
No changeset 2 in the repository

source: svn/newcon3bcm2_21bu/nexus/lib/dtcp_ip/include/bcrypt.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 27.0 KB
RevLine 
1/********************************************************************************************
2*     (c)2004-2011 Broadcom Corporation                                                     *
3*                                                                                           *
4*  This program is the proprietary software of Broadcom Corporation and/or its licensors,   *
5*  and may only be used, duplicated, modified or distributed pursuant to the terms and      *
6*  conditions of a separate, written license agreement executed between you and Broadcom    *
7*  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants*
8*  no license (express or implied), right to use, or waiver of any kind with respect to the *
9*  Software, and Broadcom expressly reserves all rights in and to the Software and all      *
10*  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU       *
11*  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY                    *
12*  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.                                 *
13*
14*  Except as expressly set forth in the Authorized License,                                 *
15*
16*  1.     This program, including its structure, sequence and organization, constitutes     *
17*  the valuable trade secrets of Broadcom, and you shall use all reasonable efforts to      *
18*  protect the confidentiality thereof,and to use this information only in connection       *
19*  with your use of Broadcom integrated circuit products.                                   *
20*                                                                                           *
21*  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"          *
22*  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR                   *
23*  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO            *
24*  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES            *
25*  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,            *
26*  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION             *
27*  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF              *
28*  USE OR PERFORMANCE OF THE SOFTWARE.                                                      *
29*                                                                                           *
30*  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS         *
31*  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR             *
32*  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR               *
33*  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF             *
34*  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT              *
35*  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE            *
36*  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF              *
37*  ANY LIMITED REMEDY.
38 *
39 * $brcm_Workfile: bcrypt.h $
40 * $brcm_Revision: 2 $
41 * $brcm_Date: 11/8/11 2:42p $
42 *
43 * Module Description:
44 *
45 * Revision History:
46 *
47 * $brcm_Log: /nexus/lib/dtcp_ip/include/bcrypt.h $
48 *
49 * 2   11/8/11 2:42p leisun
50 * SWSECURITY-86: Including original license term for bcrypt
51 *
52 * Module Description:
53 *    openssl wrapper functions from bcrypt.
54 *
55 *********************************************************************************************/
56/*! \file bcrypt.h
57 *  \brief openssl wrappers originally from bcrypt lib.
58 */
59#ifndef BCRYPT_H__
60#define BCRYPT_H__
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66#include <openssl/bn.h>
67#include "ecc.h"
68
69#define BCRYPT_LINUX_USER_MODE_DRV
70
71/* Host Secure Module magic number used to check if opaque handle is corrupt */
72#define BCRYPT_P_HANDLE_MAGIC_NUMBER           0xfeedbabe
73
74
75#define BCRYPT_P_CHECK_ERR_CODE_FUNC( errCode, function )               \
76        if( (errCode = (function)) != BERR_SUCCESS )    \
77        {                                                       \
78                errCode = BERR_TRACE(errCode);  \
79                goto BCRYPT_P_DONE_LABEL;       \
80        }                                                                       
81
82#define BCRYPT_P_CHECK_ERR_CODE_FUNC2( errCode, errCodeValue, function )                        \
83        if ( ( errCode = (function)) != BERR_SUCCESS ) \
84        {                                                                               \
85                errCode = BERR_TRACE(errCodeValue);     \
86                goto BCRYPT_P_DONE_LABEL;                                                       \
87        }
88
89       
90#define BCRYPT_P_CHECK_ERR_CODE_CONDITION( errCode, errCodeValue, condition )                   \
91        if( (condition) ) \
92        { \
93                errCode = BERR_TRACE((errCodeValue));           \
94                goto BCRYPT_P_DONE_LABEL;                                                       \
95        }       
96       
97/* Definitions */
98
99
100
101
102/* Host Secure module status codes */
103typedef enum BCRYPT_STATUS_e{
104
105        BCRYPT_STATUS_eOK,                     
106        BCRYPT_STATUS_eFAILED, 
107        BCRYPT_STATUS_eTIME_OUT,
108        BCRYPT_STATUS_eHW_BUSY_ERR,
109        BCRYPT_STATUS_eOUT_OF_SYSTEM_MEMORY,
110        BCRYPT_STATUS_eINVALID_PARAMETER
111
112} BCRYPT_STATUS_eCode;
113
114/***************************************************************************
115Summary:
116Parameters for BCRYPT handle.
117
118
119Description:
120This Structure defines the parameters for BCRYPT handle. It contains different handles
121such as HSM handle, DMA handle, and Memory DMA handle, DMA Event handle,
122HSM Mutex Handle, and DMA Mutex handle. Moreover, it contains bIsOpen and
123ulMagicNumber which must be equal to BCRYPT_P_HANDLE_MAGIC_NUMBER.
124
125
126See Also:
127BCRYPT_Setting
128
129****************************************************************************/
130typedef struct BCRYPT_P_Handle
131{
132        unsigned long                           ulMagicNumber;  /* Out: BCRYPT Magic Number */
133        bool                                            bIsOpen;                /* Out: Defines if BCRYPT handle is open */
134
135} BCRYPT_P_Handle;
136/***************************************************************************
137Summary:
138BCRYPT context handle.
139
140
141Description:
142This Structure defines BCRYPT_Handle which holds the context of BCRYPT.
143The system should have only one BCRYPT_Handle.  It is created by BCRYPT_Open function.
144The caller of BCRYPT_Open is responsible to store this BCRYPT_Handle and uses it for the
145future function calls. 
146
147
148See Also:
149BCRYPT_Open
150
151****************************************************************************/
152typedef struct BCRYPT_P_Handle * BCRYPT_Handle;
153
154
155
156BCRYPT_STATUS_eCode BCRYPT_Open(
157                BCRYPT_Handle                   *outp_handle);
158
159/*****************************************************************************
160Summary:
161This function frees the BCRYPT handle.
162
163
164Description:
165This function shall free the BCRYPT handle and any resources contained in the main handle.
166This function shall try to free any resources associated with sub handles created from the
167main handle (BCRYPT_handle).
168Regardless of the return value, this function always attempts to free all the allocated
169resources.
170System shall not call any other BCRYPT functions after calling this function.
171
172
173Calling Context:
174The function shall be called from application level or from driver level, for example in Linux
175during insmod.
176
177
178Performance and Timing:
179This is a synchronous/blocking function that will not return until it is done or failed.
180
181
182Input:
183inout_handle  - BCRYPT_Handle
184
185                       
186Returns:
187BCRYPT_STATUS_eOK - success
188BCRYPT_STATUS_eFAILED - failure
189
190
191See Also:
192BCRYPT_Open
193
194******************************************************************************/
195BCRYPT_STATUS_eCode BCRYPT_Close(
196                BCRYPT_Handle                   inout_handle);
197
198
199/***************************************************************************
200Summary:
201Parameters for SHA-1 algorithm in software.
202
203
204Description:
205This Structure defines the parameters for SHA-1 algorithm in software. It contains input
206source data, the length on input data in bytes, SHA-1 context, inital SHA-1 context, the
207generated digest, and the length of digset in bytes.
208
209****************************************************************************/
210typedef struct BCRYPT_Sha1Sw {
211        unsigned char   *pucSrcData;    /* In: A pointer to the input source data */
212        unsigned long   ulSrcDataLenInByte;     /* In: Length of the input data in bytes */
213        unsigned long ulctxnum;                         /*In: Sha1 context, MUST be within 0-15. */
214        bool   binitctx;                                        /*In: Init SHA-1 context. */
215        bool   bfinal;                                          /*In: Generate final digest. */
216
217        unsigned char   *pucDigest;             /* Out: A pointer to the output digest value */
218        unsigned char   ucDigestLenInByte;      /* Out: Length of the output digest in bytes */
219       
220}  BCRYPT_Sha1Sw_t;
221
222/* Basic Module Functions */
223
224/*****************************************************************************
225Summary:
226This function implements the SHA-1 algorithm in SW.
227
228
229Description:
230This function implements the SHA-1 algorithm in software. It is
231based on the SHA-1 implementation of the openssl code. The binaries of the openssl library is
232already included into the build environment.
233
234
235Calling Context:
236The function shall be called from application level or from driver level, for example in Linux
237during insmod.
238
239
240Performance and Timing:
241This is a synchronous/blocking function that will not return until it is done or failed.
242
243
244Input:
245hBcrypt  - BCRYPT_Handle
246inoutp_sha1SwIO - BCRYPT_Sha1Sw_t, a ref/pointer to the parameters
247                for the SW implementation of the SHA-1 algorithm.
248
249                       
250Returns:
251BCRYPT_STATUS_eOK - success
252BCRYPT_STATUS_eFAILED - failure
253
254
255******************************************************************************/
256BCRYPT_STATUS_eCode BCrypt_Sha1Sw( 
257                BCRYPT_Handle   hBcrypt,
258                BCRYPT_Sha1Sw_t         *inoutp_sha1SwIO
259);
260
261/***************************************************************************
262Summary:
263Parameters for the SW AES algorithm in the CBC mode of operation.
264
265
266Description:
267This Structure defines the parameters for the SW AES algorithm for the CBC
268mode of operation. It contains the input key, initialization vector, input and output streams,
269and the crypto mode.
270
271
272See Also:
273BCrypt_AESCBCSw
274
275****************************************************************************/
276typedef struct BCRYPT_S_AESCBCSwCtrl{
277        unsigned char   *pIn;   /* In: A pointer to the input data steam */
278        unsigned char *piv;             /* In: A pointer to the CBC initialization vector. */
279        unsigned char *pkey;            /* In: A pointer to the encryption key */
280        unsigned long   len;                    /* In: Length of the input data steam */
281        bool bEncFlag;                  /* In: Encrypt flag: 1: encrypt, 0: decrypt */
282        unsigned long keybits;          /* In: key length in bits. 128, 192, 256 only.*/
283       
284        unsigned char  *pOut;           /* Out: A pointer to the encrypted output data */
285
286} BCRYPT_S_AESCBCSwCtrl_t;
287
288
289
290
291/* Basic Module Functions */
292
293
294/*****************************************************************************
295Summary:
296This function implements the AES algorithm in the CBC mode of operation in SW.
297
298
299Description:
300This function implements the AES algorithm in the CBC mode of operation in software. It is
301based on the AES implementation of the openssl code. All key lengths of 128, 192, and 256
302are supported. The binaries of the openssl library is already included into the build
303environment. Since this is a software implementation for the AES algorithm in the CBC mode
304of operation, it can only be used with the clear key.
305If the application requires an encrypted key, then the key must be decrypted before sending
306in to this function call.
307
308
309Calling Context:
310The function shall be called from application level or from driver level, for example in Linux
311during insmod.
312
313
314Performance and Timing:
315This is a synchronous/blocking function that will not return until it is done or failed.
316
317
318Input:
319hBcrypt  - BCRYPT_Handle
320inoutp_AESCBCSwCtrl - BCRYPT_S_AESCBCSwCtrl_t, a ref/pointer to the parameters
321                for the SW implementation of the AES algorithm in the CBC mode of operation.
322
323                       
324Returns:
325BCRYPT_STATUS_eOK - success
326BCRYPT_STATUS_eFAILED - failure
327
328
329See Also:
330BCrypt_AESECBSw
331
332******************************************************************************/
333BCRYPT_STATUS_eCode BCrypt_AESCBCSw( 
334        BCRYPT_Handle   hBcrypt,
335        BCRYPT_S_AESCBCSwCtrl_t *inoutp_AESCBCSwCtrl
336);
337
338/***************************************************************************
339Summary:
340Parameters for the SW AES algorithm in the ECB mode of operation.
341
342
343Description:
344This Structure defines the parameters for the SW AES algorithm for the ECB
345mode of operation. It contains the input key, initialization vector, input and output streams,
346and the crypto mode.
347
348
349See Also:
350BCrypt_AESECBSw
351
352****************************************************************************/
353typedef struct BCRYPT_S_AESECBSwCtrl{
354        unsigned char   *pIn;   /* In: A pointer to the input data steam */
355        unsigned char *pkey;            /* In: A pointer to the encryption key */
356        unsigned long   len;                    /* In: Length of the input data steam */
357        bool bEncFlag;                  /* In: Encrypt flag: 1: encrypt, 0: decrypt */
358        unsigned long keybits;          /* In: key length in bits. 128, 192, 256 only.*/
359       
360        unsigned char  *pOut;           /* Out: A pointer to the encrypted output data */
361
362} BCRYPT_S_AESECBSwCtrl_t;
363
364
365
366
367/* Basic Module Functions */
368
369
370/*****************************************************************************
371Summary:
372This function implements the AES algorithm in the ECB mode of operation in SW.
373
374
375Description:
376This function implements the AES algorithm in the ECB mode of operation in software. It is
377based on the AES implementation of the openssl code. All key lengths of 128, 192, and 256
378are supported. The binaries of the openssl library is already included into the build
379environment. Since this is a software implementation for the AES algorithm in the ECB mode
380of operation, it can only be used with the clear key.
381If the application requires an encrypted key, then the key must be decrypted before sending
382in to this function call.
383
384
385Calling Context:
386The function shall be called from application level or from driver level, for example in Linux
387during insmod.
388
389
390Performance and Timing:
391This is a synchronous/blocking function that will not return until it is done or failed.
392
393
394Input:
395hBcrypt  - BCRYPT_Handle
396inoutp_AESECBSwCtrl - BCRYPT_S_AESECBSwCtrl_t, a ref/pointer to the parameters
397                for the SW implementation of the AES algorithm in the ECB mode of operation.
398
399                       
400Returns:
401BCRYPT_STATUS_eOK - success
402BCRYPT_STATUS_eFAILED - failure
403
404
405See Also:
406BCrypt_AESECBSw
407
408******************************************************************************/
409BCRYPT_STATUS_eCode BCrypt_AESECBSw( 
410        BCRYPT_Handle   hBcrypt,
411        BCRYPT_S_AESECBSwCtrl_t *inoutp_AESECBSwCtrl
412);
413
414/***************************************************************************
415Summary:
416Parameters for Elliptic Curve.
417
418
419Description:
420This Structure defines the parameters for Elliptic Curve. It contains modulus P, elliptic curve
421coefficient A and B, the base point G with components X and Y, and the order of base point
422G.
423
424
425See Also:
426BCRYPT_ECCPoint
427
428****************************************************************************/
429typedef struct BCRYPT_ECCParam
430{
431        char    *P;                             /* In: Modulus */
432        char    *A;                             /* In: Elliptic curve coefficient a */
433        char    *B;                             /* In: Elliptic curve coefficient b */
434        char    *G_x;                   /* In: Base point, X component */
435        char    *G_y;                   /* In: Base point, Y component */
436        char    *N;                             /* In: Order of base point G */
437} BCRYPT_ECCParam_t;
438
439
440/***************************************************************************
441Summary:
442Parameters for a point on an EC curve.
443
444
445Description:
446This Structure defines the parameters a point on an EC curve. It contains the components
447x and y of the point on an EC curve.
448
449
450See Also:
451BCRYPT_ECCParam
452
453****************************************************************************/
454typedef struct BCRYPT_ECCPoint         
455{
456        char    *x;                             /* In: Component x of the point in EC curve*/
457        char    *y;                             /* In: Component y of the point in EC curve*/
458} BCRYPT_ECCPoint_t;
459
460
461/*
462 * Signature
463 */
464typedef enum
465{
466        BCRYPT_ECCSig_Format_Decimal = 0,
467        BCRYPT_ECCSig_Format_Hex
468}       BCRYPT_ECCSig_Format_t;
469
470
471/***************************************************************************
472Summary:
473Parameters for a ECC signature.
474
475
476Description:
477This Structure defines the parameters for ECC signature. It contains r, s (signature) and the
478signature format.
479
480
481See Also:
482BCRYPT_ECCParam, BCRYPT_ECCPoint
483
484****************************************************************************/
485typedef struct BCRYPT_ECCSig
486{
487        char                                    *r;                             /* In: Component r of ECC signature*/
488        char                                    *s;                             /* In: Component s of ECC signature*/
489        BCRYPT_ECCSig_Format_t  format;         /* In: Signature format*/
490} BCRYPT_ECCSig_t;
491
492
493/*
494 * Public key
495 */
496typedef BCRYPT_ECCPoint_t BCRYPT_ECCPublicKey_t;
497
498
499
500/***************************************************************************
501Summary:
502Parameters for a ECDSA Verify.
503
504
505Description:
506This Structure defines the parameters for ECDSA Verify. It contains EC curve parameters,
507signature, public key, hash string and its length, and a flag indicating if signature is valid.
508
509
510See Also:
511BCRYPT_ECCParam, BCRYPT_ECCPoint, BCRYPT_ECCSig
512BCRYPT_ECDSASw_Sign, BCRYPT_ECDSASw_Multiply
513
514****************************************************************************/
515typedef struct BCRYPT_ECDSASw_Verify
516{
517        BCRYPT_ECCParam_t               eccParm;        /* In: EC curve parameters */
518        BCRYPT_ECCSig_t                 sig;                    /* In: ECC Signature */
519        BCRYPT_ECCPublicKey_t   publicKey;      /* In: Public key */
520        unsigned char                   *hash;                  /* In: A pointer to hash string */
521        unsigned char                   hashLen;                /* In: Length of hash */
522        bool                                    sigIsValid;             /* Out: A flag indicating signature is valid */
523}  BCRYPT_ECDSASw_Verify_t;
524
525
526
527/***************************************************************************
528Summary:
529Parameters for a ECDSA Sign.
530
531
532Description:
533This Structure defines the parameters for ECDSA Sign. It contains EC curve parameters,
534signature, private key, hash string and its length, and a random integer.
535
536
537See Also:
538BCRYPT_ECCParam, BCRYPT_ECCPoint, BCRYPT_ECCSig
539BCRYPT_ECDSASw_Verify, BCRYPT_ECDSASw_Multiply
540
541****************************************************************************/
542typedef struct BCRYPT_ECDSASw_Sign
543{
544        BCRYPT_ECCParam_t               eccParm;        /* In: EC curve parameters */
545        BCRYPT_ECCSig_t                 sig;                    /* In: ECC Signature */
546        unsigned char                   *hash;                  /* In: A pointer to hash string */
547        unsigned char                   hashLen;                        /* In: Length of hash */
548        char                                    *k;                             /* In: A random integer k */
549        char                                    *privateKey;            /* In: Private key */
550}  BCRYPT_ECDSASw_Sign_t;
551
552
553
554/***************************************************************************
555Summary:
556Parameters for a  EC Scalar Multiplication.
557
558
559Description:
560This Structure defines the parameters for  EC Scalar Multiplication. It contains EC curve parameters,
561scalar, input point, and the output point.
562
563See Also:
564BCRYPT_ECCParam, BCRYPT_ECCPoint, BCRYPT_ECCSig
565BCRYPT_ECDSASw_Sign, BCRYPT_ECDSASw_Verify
566
567****************************************************************************/
568typedef struct BCRYPT_ECDSASw_Multiply
569{
570        BCRYPT_ECCParam_t       eccParm;        /* In: EC curve parameters */
571        char                                    *scalar;                /* In: Scalar value */
572        BCRYPT_ECCPoint_t       inPoint;                /* In: Input point */
573        BCRYPT_ECCPoint_t       outPoint;       /* Out: output point, result of Scalar Multiplication */
574}  BCRYPT_ECDSASw_Multiply_t;
575
576
577
578
579/* ECDSA functions */
580
581
582/*****************************************************************************
583Summary:
584This function implements the ECDSA Verify algorithm in SW.
585
586
587Description:
588This function implements the ECDSA Verify algorithm in software. It is based on the ECDSA
589implementation of the openssl code. The binaries of the openssl library is already included
590into the build environment.
591
592
593Calling Context:
594The function shall be called from application level or from driver level, for example in Linux
595during insmod.
596
597
598Performance and Timing:
599This is a synchronous/blocking function that will not return until it is done or failed.
600
601
602Input:
603hBcrypt  - BCRYPT_Handle
604inoutp_ecdsaSwIO - BCRYPT_ECDSASw_Verify_t, a ref/pointer to the parameters
605                for the SW implementation of the ECDSA Verify algorithm.
606
607                       
608Returns:
609BCRYPT_STATUS_eOK - success
610BCRYPT_STATUS_eFAILED - failure
611
612
613See Also:
614BCrypt_ECDSASignSw, BCrypt_ECDSAMultiplySw
615
616******************************************************************************/
617BCRYPT_STATUS_eCode BCrypt_ECDSAVerifySw( 
618                BCRYPT_Handle                           hBcrypt,
619                BCRYPT_ECDSASw_Verify_t         *inoutp_ecdsaSwIO
620);
621
622
623
624/*****************************************************************************
625Summary:
626This function implements the ECDSA Sign algorithm in SW.
627
628
629Description:
630This function implements the ECDSA Sign algorithm in software. It is based on the ECDSA
631implementation of the openssl code. The binaries of the openssl library is already included
632into the build environment.
633
634
635Calling Context:
636The function shall be called from application level or from driver level, for example in Linux
637during insmod.
638
639
640Performance and Timing:
641This is a synchronous/blocking function that will not return until it is done or failed.
642
643
644Input:
645hBcrypt  - BCRYPT_Handle
646inoutp_ecdsaSwIO - BCRYPT_ECDSASw_Sign_t, a ref/pointer to the parameters
647                for the SW implementation of the ECDSA Sign algorithm.
648
649                       
650Returns:
651BCRYPT_STATUS_eOK - success
652BCRYPT_STATUS_eFAILED - failure
653
654
655See Also:
656BCrypt_ECDSAVerifySw, BCrypt_ECDSAMultiplySw
657
658******************************************************************************/
659BCRYPT_STATUS_eCode BCrypt_ECDSASignSw( 
660                BCRYPT_Handle                           hBcrypt,
661                BCRYPT_ECDSASw_Sign_t           *inoutp_ecdsaSwIO
662);
663
664
665/*****************************************************************************
666Summary:
667This function cleans up the ECDSA paramter allocated by OpenSSL.
668
669
670Description:
671This function cleans the ECDSA paramter allocated by OpenSSL. Specifically, during the
672call to ECDSASignSw the function allocates memory for the sig.r or sig.s
673using the BN_bn2dec or BN_bn2hex these needs to be freed by calling the OPNESSL_free once.
674Thius function allows the user of the ECDSASignSw to free up these memory
675once it has done using them.
676
677Calling Context:
678The function shall be called from application level or from driver level, for example in Linux
679during insmod.
680
681Performance and Timing:
682This is a synchronous/blocking function that will not return until it is done or failed.
683
684
685Input:
686hBcrypt  - BCRYPT_Handle
687inoutp_ecdsaSwIO - BCRYPT_ECDSASw_Sign_t, a ref/pointer to the parameters
688                for the SW implementation of the ECDSA Sign algorithm.
689
690                       
691Returns:
692BCRYPT_STATUS_eOK - success
693BCRYPT_STATUS_eFAILED - failure
694
695
696See Also:
697BCrypt_ECDSAVerifySw, BCrypt_ECDSAMultiplySw
698
699******************************************************************************/
700BCRYPT_STATUS_eCode BCrypt_Sign_ECDSAClean( 
701                BCRYPT_Handle                           hBcrypt,
702                BCRYPT_ECDSASw_Sign_t           *inoutp_ecdsaSwIO
703);
704
705
706
707/*****************************************************************************
708Summary:
709This function cleans up the ECDSA paramter allocated by OpenSSL.
710
711
712Description:
713This function cleans the ECDSA paramter allocated by OpenSSL. Specifically, during the
714call to ECDSAMultiplySw the function allocates memory for the sig.r or sig.s
715using the BN_bn2dec or BN_bn2hex these needs to be freed by calling the OPNESSL_free once.
716Thius function allows the user of the ECDSAMultiplySw to free up these memory
717once it has done using them.
718
719Calling Context:
720The function shall be called from application level or from driver level, for example in Linux
721during insmod.
722
723Performance and Timing:
724This is a synchronous/blocking function that will not return until it is done or failed.
725
726
727Input:
728hBcrypt  - BCRYPT_Handle
729inoutp_ecdsaSwIO - BCRYPT_ECDSASw_Multiply_t, a ref/pointer to the parameters
730                for the SW implementation of the ECDSA Sign algorithm.
731
732                       
733Returns:
734BCRYPT_STATUS_eOK - success
735BCRYPT_STATUS_eFAILED - failure
736
737
738See Also:
739BCrypt_Sign_ECDSAClean
740
741******************************************************************************/
742BCRYPT_STATUS_eCode BCrypt_Multiply_ECDSAClean( 
743                BCRYPT_Handle                           hBcrypt,
744                BCRYPT_ECDSASw_Multiply_t               *inoutp_ecdsaSwIO
745);
746
747
748
749
750/*****************************************************************************
751Summary:
752This function implements the EC Scalar Multiplication algorithm in SW.
753
754
755Description:
756This function implements theEC Scalar Multiplication algorithm in software. It is based on the
757EC Scalar Multiplication implementation of the openssl code. The binaries of the openssl library
758is already included into the build environment.
759
760
761Calling Context:
762The function shall be called from application level or from driver level, for example in Linux
763during insmod.
764
765
766Performance and Timing:
767This is a synchronous/blocking function that will not return until it is done or failed.
768
769
770Input:
771hBcrypt  - BCRYPT_Handle
772inoutp_ecdsaSwIO - BCRYPT_ECDSASw_Multiply_t, a ref/pointer to the parameters
773                for the SW implementation of the EC Scalar Multiplication algorithm.
774
775                       
776Returns:
777BCRYPT_STATUS_eOK - success
778BCRYPT_STATUS_eFAILED - failure
779
780
781See Also:
782BCrypt_ECDSASignSw, BCrypt_ECDSAVerifySw
783
784******************************************************************************/
785BCRYPT_STATUS_eCode BCrypt_ECDSAMultiplySw( 
786                BCRYPT_Handle                           hBcrypt,
787                BCRYPT_ECDSASw_Multiply_t       *inoutp_ecdsaSwIO
788);
789
790
791
792/* Number conversion utility functions */
793typedef enum
794{
795        BCRYPT_String_Format_Decimal = 0,
796        BCRYPT_String_Format_Hex
797}       BCRYPT_String_Format_t;
798
799
800
801/*****************************************************************************
802Summary:
803This function Converts Binary to String.
804
805
806Description:
807This function Converts Binary to String. It is based on the implementation of the openssl code.
808The binaries of the openssl library is already included into the build environment.
809
810
811Calling Context:
812The function shall be called from application level or from driver level, for example in Linux
813during insmod.
814
815
816Performance and Timing:
817This is a synchronous/blocking function that will not return until it is done or failed.
818
819
820Input:
821hBcrypt  - BCRYPT_Handle
822data - unsigned char,  a ref/pointer to data to be converted .
823byteLen - unsigned long, length of data in bytes.
824format - BCRYPT_String_Format_t,  format of input string.
825
826
827Output:
828outStr - char, a ref/pointer to output string.
829
830                       
831Returns:
832BCRYPT_STATUS_eOK - success
833BCRYPT_STATUS_eFAILED - failure
834
835
836See Also:
837BCrypt_ConvStrToBin
838
839******************************************************************************/
840BCRYPT_STATUS_eCode BCrypt_ConvBinToStr( 
841                BCRYPT_Handle                           hBcrypt,       
842                unsigned char                           *data,         
843                unsigned long                           byteLen,       
844                BCRYPT_String_Format_t          format,         
845                char                                            *outStr
846);
847
848
849/*****************************************************************************
850Summary:
851This function Converts String to Binary.
852
853
854Description:
855This function Converts String to Binary. It is based on the implementation of the openssl code.
856The binaries of the openssl library is already included into the build environment.
857
858
859Calling Context:
860The function shall be called from application level or from driver level, for example in Linux
861during insmod.
862
863
864Performance and Timing:
865This is a synchronous/blocking function that will not return until it is done or failed.
866
867
868Input:
869hBcrypt  - BCRYPT_Handle
870inStr - char, a ref/pointer to input string.
871format - BCRYPT_String_Format_t,  format of input string.
872
873
874Output:
875data - unsigned char,  a ref/pointer to binary data.
876byteLen - unsigned long, a ref/pointer to the length of data in bytes.
877
878                       
879Returns:
880BCRYPT_STATUS_eOK - success
881BCRYPT_STATUS_eFAILED - failure
882
883
884See Also:
885BCrypt_ConvBinToStr
886
887******************************************************************************/
888BCRYPT_STATUS_eCode BCrypt_ConvStrToBin( 
889                BCRYPT_Handle                           hBcrypt,       
890                char                                            *inStr,         
891                BCRYPT_String_Format_t          format,         
892                unsigned char                           *data,         
893                unsigned long                           *byteLen       
894);
895
896
897#ifdef __cplusplus
898}
899#endif
900
901#endif /* BCRYPT_H__ */
902
903
904
905
906
907
908
Note: See TracBrowser for help on using the repository browser.