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 30extern "C" { 31#endif 32 33/* 34 * Support for bytestream key and signature representation. 35 */ 36int intToByteRep(int i, unsigned char *buf); 37int shortToByteRep(short s, unsigned char *buf); 38int giantToByteRep(giant g, unsigned char *buf); 39int keyToByteRep(key k, unsigned char *buf); 40int curveParamsToByteRep(curveParams *cp, unsigned char *buf); 41int sigToByteRep(int magic, 42 int version, 43 int minVersion, 44 giant g0, 45 giant g1, 46 unsigned char *buf); 47 48int lengthOfByteRepGiant(giant g); 49int lengthOfByteRepKey(key k); 50int lengthOfByteRepCurveParams(curveParams *cp); 51int lengthOfByteRepSig(giant g0, 52 giant g1); 53 54int byteRepToInt(const unsigned char *buf); 55unsigned short byteRepToShort(const unsigned char *buf); 56giant byteRepToGiant(const unsigned char *buf, 57 unsigned bufLen, 58 unsigned *giantLen); 59key byteRepToKey(const unsigned char *buf, 60 unsigned bufLen, 61 int twist, 62 curveParams *cp, 63 unsigned *keyLen); // returned 64curveParams *byteRepToCurveParams(const unsigned char *buf, 65 unsigned bufLen, 66 unsigned *cpLen); 67int 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_*/ 81