Calling CryptMsgCalculateEncodedLength causes GetLastError = 183 ERROR_ALREADY_EXISTS



Hi,

All my calls to CryptMsgCalculateEncodedLength and / or CryptMsgUpdate
return LastError 183 ERROR_ALREADY_EXISTS. Does anyone know what
ERROR_ALREADY_EXISTS means in the CAPI Msg context? I have a string
signed with szOID_RSA_SHA1RSA that I was trying to add to a message.
I tried a non-encoded string similar to the following and got the same
183 (GetLastError is 0 prior to the call):

BYTE str[27] = "AAAAAAAAAAAAAAAAAAAAAAAAAA";

if( !CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV,
PROV_RSA_FULL, CRYPT_SILENT) )
{
printf("\nCryptAcquireContext GetLastError %ld",
GetLastError());
return FALSE;
}

if( !(msgLen = CryptMsgCalculateEncodedLength(ALL_ENCODING_TYPES, 0
, CMSG_DATA, str, szOID_RSA_SHA1RSA , 27)) )


I've tried many variations and I always get 183. Any suggestions are
greatly appreciated.

Thanks!
.