[prev in list] [next in list] [prev in thread] [next in thread]
List: ms-cryptoapi
Subject: R: Problem with low-level functions (hash data file)
From: "Carucci, Giuseppe (Olivettiricerca)"
Date: 2000-09-12 9:29:58
[Download RAW message or body]
In my previous mail (see below), the error returned by CryptMsgOpenToEncode
function is not (excuse me) CRYPT_E_MSG_ERROR, but CRYPT_E_UNKNOW_ALGO!
I suppose that the problem is the hash algorithm (szOID_RSA_SHA1RSA) because
with szOID_RSA_MD5 the function CryptMsgOpenToEncode returns OK.
But the stream callback function is not called by CryptMsgUpdate; then I
have not generated
a hashed file (attached mode).
How I can do to use the SHA1 hash algorithm !? Why the callback is not
called !?
I will precise that a callback is used in my program to sign file (attached
mode) and functions
correctly! With CMSG_HASHED flag I can't to use the stream callback!!?
Thanks in advance.
Carucci Giuseppe
Olivetti Ricerca SCpA (Getronics Group)
tel. 0806352056
Contrada La Marchesa - SS 271 KM 8,3
70020 Bitritto (BA)
mail: Giuseppe.Carucci@getronics.com
///
(. .)
---------------------------------oOO--(_)--OOo----------------------
> -----Messaggio originale-----
> Da: Carucci, Giuseppe (Olivettiricerca)
> [SMTP:Giuseppe.Carucci@GETRONICS.COM]
> Inviato: marted́ 12 settembre 2000 10.19
> A: CryptoAPI@DISCUSS.MICROSOFT.COM
> Oggetto: Problem with low-level functions (hash data file)
>
> I am using low-level functions with streaming (to read a file) to encode
> and
> to hash data (attached mode).
>
> I have implemented the hash with low-level API (CryptMsgOpenToEncode,
> CryptMsgUpdate, etc) and a callback function to write a file that contains
> the data and digest in PKCS#7 format; but when I call CryptMsgOpenToEncode
> I have the error CRYPT_E_MSG_ERROR (you can see my code below).
>
> I call CryptAcquireContext to get a handle to a provider.
> Is this necessary? Or I can to pass the value 0 to
> HashedEncodeInfo.hCryptProv?
>
> Is there an incorrect parameter? Or where is the problem?
>
> Thanks in advance.
>
> // Get a handle to a cryptographic provider.
> ....
> CryptAcquireContext(&phProv, NULL, NULL, PROV_RSA_FULL,
> CRYPT_VERIFYCONTEXT)
> ....
>
> // Initialize the algorithm identifier structure.
> ....
> HashAlgorithm.pszObjId = szOID_RSA_SHA1RSA;
> ....
>
> // Initialize the CMSG_HASHED_ENCODE_INFO structure.
> HashedEncodeInfo.hCryptProv = phProv;
> HashedEncodeInfo.HashAlgorithm = HashAlgorithm;
> HashedEncodeInfo.pvHashAuxInfo = NULL;
>
> // Input file
> hInFile = CreateFile(...);
> // Output file, containing your hashed data (in a PKCS7 format)
> hOutFile = CreateFile(...);
>
> ....
>
> // fill the StreamInfo struct
> StreamInfo.cbContent = dwInFileLen;
> StreamInfo.pfnStreamOutput = &StreamCallback;
> StreamInfo.pvArg = &hOutFile;
>
> // Open a message for encoding mode attach or detach
> hMsg = CryptMsgOpenToEncode(
> ENCODING_TYPE, // Encoding type.
> 0, // Flags.
> CMSG_HASHED, // message type.
> &HashedEncodeInfo, // Pointer to structure
> NULL, // Inner content OID.
> &StreamInfo); // Stream information.
> if (hMsg == NULL)
> {
> .........................................
> .........................................
> My error is : CRYPT_E_MSG_ERROR
> .........................................
> .........................................
> }
>
> ....
>
>
> Carucci Giuseppe
> Olivetti Ricerca SCpA (Getronics Group)
> tel. 0806352056
>
> Contrada La Marchesa - SS 271 KM 8,3
> 70020 Bitritto (BA)
> mail: Giuseppe.Carucci@getronics.com
>
> ///
> (. .)
> ---------------------------------oOO--(_)--OOo----------------------
>
> ----------------------------------------------------------------
> Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
> contains important info including how to unsubscribe. Save time, search
> the archives at http://discuss.microsoft.com/archives/index.html
----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://discuss.microsoft.com/archives/index.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic