byteRep.h
1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved. 2 * 3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT 4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE 5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE 6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE, 7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL 8 * EXPOSE YOU TO LIABILITY. 9 *************************************************************************** 10 * 11 * byteRep.h - FEE portable byte representation support 12 * 13 * Revision History 14 * ---------------- 15 * 17 Jul 97 at Apple 16 * Added signature routines. 17 * 9 Jan 97 at NeXT 18 * Split off from ckutilities.h 19 */ 20 21 #ifndef _CK_BYTEREP_H_ 22 #define _CK_BYTEREP_H_ 23 24 #include "feeTypes.h" 25 #include "giantIntegers.h" 26 #include "elliptic.h" 27 #include "curveParams.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* 34 * Support for bytestream key and signature representation. 35 */ 36 int intToByteRep(int i, unsigned char *buf); 37 int shortToByteRep(short s, unsigned char *buf); 38 int giantToByteRep(giant g, unsigned char *buf); 39 int keyToByteRep(key k, unsigned char *buf); 40 int curveParamsToByteRep(curveParams *cp, unsigned char *buf); 41 int sigToByteRep(int magic, 42 int version, 43 int minVersion, 44 giant g0, 45 giant g1, 46 unsigned char *buf); 47 48 int lengthOfByteRepGiant(giant g); 49 int lengthOfByteRepKey(key k); 50 int lengthOfByteRepCurveParams(curveParams *cp); 51 int lengthOfByteRepSig(giant g0, 52 giant g1); 53 54 int byteRepToInt(const unsigned char *buf); 55 unsigned short byteRepToShort(const unsigned char *buf); 56 giant byteRepToGiant(const unsigned char *buf, 57 unsigned bufLen, 58 unsigned *giantLen); 59 key byteRepToKey(const unsigned char *buf, 60 unsigned bufLen, 61 int twist, 62 curveParams *cp, 63 unsigned *keyLen); // returned 64 curveParams *byteRepToCurveParams(const unsigned char *buf, 65 unsigned bufLen, 66 unsigned *cpLen); 67 int byteRepToSig(const unsigned char *buf, 68 unsigned bufLen, 69 int codeVersion, 70 int *sigMagic, // RETURNED 71 int *sigVersion, // RETURNED 72 int *sigMinVersion, // RETURNED 73 giant *g0, // alloc'd & RETURNED 74 giant *g1); // alloc'd & RETURNED 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 #endif /*_CK_BYTEREP_H_*/