1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - include 3 File: crypto/util.h 4 5 Copyright 2003-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2008-09-17#$ 14 $Rev: 8556 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NITRO_CRYPTO_UTIL_H_ 19 #define NITRO_CRYPTO_UTIL_H_ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #include <nitro/types.h> 26 27 /*---------------------------------------------------------------------------* 28 Name: CRYPTO_SetAllocator 29 30 Description: This function registers the memory management function to be used with the CRYPTO library. 31 This function has been left for backwards compatibility. 32 33 Arguments: alloc - pointer to the memory allocation function 34 free - pointer to the memory release function 35 36 Returns: None. 37 *---------------------------------------------------------------------------*/ 38 #define CRYPTO_SetAllocator(alloc, free) CRYPTO_SetMemAllocator(alloc, free, NULL) 39 40 41 /*---------------------------------------------------------------------------* 42 Name: CRYPTO_SetMemAllocator 43 44 Description: This function registers the memory management function to be used with the CRYPTO library. 45 46 Arguments: alloc - pointer to the memory allocation function 47 free - pointer to the memory release function 48 realloc - Pointer to a function for changing the memory size 49 50 Returns: None. 51 *---------------------------------------------------------------------------*/ 52 void CRYPTO_SetMemAllocator( 53 void* (*alloc) (u32), 54 void (*free) (void*), 55 void* (*realloc) (void*,u32,u32) 56 ); 57 58 59 60 #define BER_INTEGER 2 61 #define BER_BIT_STRING 3 62 #define BER_OCTET_STRING 4 63 #define BER_NULL 5 64 #define BER_OBJECT 6 65 #define BER_SEQUENCE 16 66 #define BER_CONSTRUCTED 0x20 67 68 /*---------------------------------------------------------------------------* 69 Name: CRYPTO_DerSkip 70 71 Description: Skips the tag and length fields of ASN.1 (DER) objects. 72 73 74 Arguments: datap - Pointer to a buffer 75 dlenp - Buffer length 76 type - Tag number 77 lenp - Value of the length field 78 79 Returns: 1 : Skipped successfully 80 0 : Failed to skip 81 *---------------------------------------------------------------------------*/ 82 int 83 CRYPTO_DerSkip( 84 unsigned char **datap, 85 unsigned int *dlenp, 86 unsigned char type, 87 unsigned int *lenp 88 ); 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 #endif //_NITRO_CRYPTO_UTIL_H_ 95