/*
 * Obtain Pm after feeSigNewWithKey() or feeSigParse()
 */
unsigned char *feeSigPm(feeSig sig,
	unsigned *PmLen)
{
	sigInst *sinst = (sigInst*) sig;
	unsigned char *Pm;

	if(sinst->PmX == NULL) {
		dbgLog(("feeSigPm: no PmX!\n"));
		return NULL;
	}
	else {
		Pm = mem_from_giant(sinst->PmX, PmLen);
		#if	SIG_DEBUG
		if(sigDebug)
		{
		    int i;

		    printf("Pm : "); printGiant(sinst->PmX);
		    printf("PmData: ");
		    for(i=0; i<*PmLen; i++) {
		        printf("%x:", Pm[i]);
		    }
		    printf("\n");
		}
		#endif	// SIG_DEBUG
	}
	return Pm;
}
feeReturn feePubKeyCreatePad(feePubKey myKey,
	feePubKey theirKey,
	unsigned char **padData,	/* RETURNED */
	unsigned *padDataLen)		/* RETURNED padData length in bytes */
{
	pubKeyInst *myPkinst = (pubKeyInst *) myKey;
	pubKeyInst *theirPkinst = (pubKeyInst *) theirKey;
	giant pad;
	unsigned char *result;
    	unsigned padLen;
	key pkey;

	/*
	 * Do some compatibility checking (myKey, theirKey) here...?
	 */
	if(DEFAULT_CURVE == CURVE_PLUS) {
		pkey = theirPkinst->plus;
	}
	else {
		pkey = theirPkinst->minus;
	}
	pad = make_pad(myPkinst->privGiant, pkey);
	result = mem_from_giant(pad, &padLen);
	freeGiant(pad);

	/*
	 * Ensure we have a the minimum necessary for DES. A bit of a hack,
	 * to be sure.
	 */
	if(padLen >= FEE_DES_MIN_STATE_SIZE) {
		*padData = result;
		*padDataLen = padLen;
	}
	else {
		*padData = (unsigned char*) fmalloc(FEE_DES_MIN_STATE_SIZE);
		*padDataLen = FEE_DES_MIN_STATE_SIZE;
		bzero(*padData, FEE_DES_MIN_STATE_SIZE);
		bcopy(result, *padData, padLen);
		ffree(result);
	}
	return FR_Success;
}