Re: [Cdsa-dev] problem whith CSSM_WrapKey. help me, please.
Status: Abandoned
Brought to you by:
mdwood-intel
From: Tom W. <woo...@zk...> - 2002-03-01 21:19:56
|
Pietro, What you are trying to do works fine for me. I have one program that generates an RSA key pair and then uses the public key to wrap a DES key. That same public key is hard-coded into a second program which also uses it to wrap a DES key. Both work fine. Here are two things to check in your program: 1. Check the way that you re-construct the public key from the file. Here is how I did it: memset(&PubKey, 0, sizeof PubKey); PubKey.KeyHeader.HeaderVersion = CSSM_KEYHEADER_VERSION; PubKey.KeyHeader.BlobType = CSSM_KEYBLOB_RAW; PubKey.KeyHeader.Format = CSSM_KEYBLOB_RAW_FORMAT_PKCS1; PubKey.KeyHeader.AlgorithmId = CSSM_ALGID_RSA; PubKey.KeyHeader.KeyClass = CSSM_KEYCLASS_PUBLIC_KEY; PubKey.KeyHeader.LogicalKeySizeInBits = 512; PubKey.KeyHeader.KeyUsage = CSSM_KEYUSE_WRAP; PubKey.KeyHeader.WrapAlgorithmId = CSSM_ALGID_NONE; uint8 PubKeyBits[] = { ... }; PubKey.KeyData.Length = sizeof PubKeyBits; PubKey.KeyData.Data = PubKeyBits; 2. Initialize the entire WrappedKey structure to 0 before passing it to CSSM_WrapKey(), for example: memset(&WrappedKey, 0, sizeof WrappedKey); I will send you a copy of my program in a separate e-mail. Regards, Tom |