Легенда:
новое сообщение
закрытая нитка
новое сообщение
в закрытой нитке
старое сообщение
|
- Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
- Новичкам также крайне полезно ознакомиться с данным документом.
ребят, это конечно всё хорошо, но... =) 13.06.06 14:42 Число просмотров: 3448
Автор: nop Статус: Незарегистрированный пользователь
|
В общем, дело такое:
char *buffer;
int status, blockSize = 10;
CRYPT_ALGO_TYPE cryptAlgo = CRYPT_ALGO_RSA;
CRYPT_CONTEXT cryptContext;
CRYPT_KEYSET cryptKeyset;
/* Initialise cryptlib */
status = cryptInit();
if(cryptStatusError(status)) {
printf( "cryptInit() failed with error code %d.\n", status );
exit(EXIT_FAILURE);
}
buffer = (char *)malloc(300);
memset(buffer,'\x00',300);
memcpy(buffer,"hello world!",sizeof("hello world!"));
cryptCreateContext( &cryptContext, CRYPT_UNUSED, CRYPT_ALGO_RSA );
cryptSetAttributeString( cryptContext, CRYPT_CTXINFO_LABEL,"AAAAAAAAAAAAAA", 14 );
cryptGenerateKey( cryptContext );
printf("buffer: %s, len: %i\n",buffer, strlen(buffer));
status = cryptEncrypt( cryptContext, buffer, strlen(buffer));
if(cryptStatusError(status)) {
printf( "cryptEncrypt() failed with error code %d.\n", status );
exit(EXIT_FAILURE);
}
Вот что выводится на экран:
buffer: hello world!, len: 12
cryptEncrypt() failed with error code -3.
-3 в заголовках прописана как:
/* No error in function call */
#define CRYPT_OK 0 /* No error */
/* Error in parameters passed to function */
#define CRYPT_ERROR_PARAM1 -1 /* Bad argument, parameter 1 */
#define CRYPT_ERROR_PARAM2 -2 /* Bad argument, parameter 2 */
#define CRYPT_ERROR_PARAM3 -3 /* Bad argument, parameter 3 */
#define CRYPT_ERROR_PARAM4 -4 /* Bad argument, parameter 4 */
#define CRYPT_ERROR_PARAM5 -5 /* Bad argument, parameter 5 */
#define CRYPT_ERROR_PARAM6 -6 /* Bad argument, parameter 6 */
#define CRYPT_ERROR_PARAM7 -7 /* Bad argument, parameter 7 */
То есть получается ошибка в 3-ем аргументе. Там передаётся длина данных. Какая там может быть ошибка? :\
|
|
|