Exemplo n.º 1
0
/*
 * Encode to/from byteRep.
 */
static void ECDSA_encode(
    feeSigFormat format,          // Signature format DER 9.62 / RAW
    unsigned groupBytesLen,
    giant c,
	giant d,
	unsigned char **sigData,		// malloc'd and RETURNED
	unsigned *sigDataLen)			// RETURNED
{
	#if	CRYPTKIT_DER_ENABLE
    if (format==FSF_RAW) {
        feeRAWEncodeECDSASignature(groupBytesLen,c, d, sigData, sigDataLen);
    } else {
        feeDEREncodeECDSASignature(c, d, sigData, sigDataLen);
    }
	#else
	*sigDataLen = lengthOfByteRepSig(c, d);
	*sigData = (unsigned char*) fmalloc(*sigDataLen);
	sigToByteRep(FEE_ECDSA_MAGIC,
		FEE_ECDSA_VERSION,
		FEE_ECDSA_VERSION_MIN,
		c,
		d,
		*sigData);
	#endif
}
/*
 * Given a feeSig processed by feeSigSign, obtain a malloc'd byte
 * array representing the signature.
 * See ByteRep.doc for info on the format of the signature string;
 * PLEASE UPDATE THIS DOCUMENT WHEN YOU MAKE CHANGES TO THE STRING FORMAT.
 */
feeReturn feeSigData(feeSig sig,
	unsigned char **sigData,		// IGNORED....malloc'd and RETURNED
	unsigned *sigDataLen)			// RETURNED
{
	sigInst  *sinst = (sigInst*) sig;

	#if		CRYPTKIT_DER_ENABLE
	return feeDEREncodeElGamalSignature(sinst->u, sinst->PmX, sigData, sigDataLen);
	#else
	*sigDataLen = lengthOfByteRepSig(sinst->u, sinst->PmX);
	*sigData = (unsigned char*) fmalloc(*sigDataLen);
	sigToByteRep(FEE_SIG_MAGIC,
		FEE_SIG_VERSION,
		FEE_SIG_VERSION_MIN,
		sinst->u,
		sinst->PmX,
		*sigData);
	return FR_Success;
	#endif
}