06.08.2004 12:10:57CryptEncryptMessage Ответов: 1
Евгений
Помогите, пожалуйста. Пользуюсь функцией CryptEncryptMessage, криптопровайдер - CryptoPro CSP. Передаем функции одни и те же параметры. Но вызываем ее два раза, один раз с NULL вместо указателя на буфер для зашифрованных данных. А второй раз уже с указателем. Ну все по науке, чтобы выделить память нужного размера. Только вот в первый раз функция возвращает размер буфера в два раза больший, чем реально получаются зашифрованные данные. Нормально ли это? И как обычно получается? И можно ли на это забить? Все таки беспокоит этот факт...
 
Ответы:
09.08.2004 12:16:55Василий
Вот что пишут в MSDN об этом:

pcbEncryptedBlob
[in, out] Pointer to a DWORD that specifies the size, in bytes, of the buffer pointed to by the pbEncryptedBlob parameter. When the function returns, this variable contains the size, in bytes, of the encrypted and encoded message copied to pbEncryptedBlob.
Note When processing the data returned in the buffer of the pbEncryptedBlob, applications need to use the actual size of the data returned. The actual size can be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.