Статус: Новичок
Группы: Участники
Зарегистрирован: 03.04.2008(UTC) Сообщений: 9 Откуда: Finland
|
Добрый день.
В пакете ISAKMP SA получаем симметричный ключ. Каким образом его импортировать ? Ниже приведенная функция не работает, непоскажете где ошибка ?
int csp_create_G28147_key( csp_key_t *key, const csp_byte_t *data, csp_uint_t length ) {
BYTE G28147_key_blob[8 + 4 + 32]; BLOBHEADER *header; int rcode;
assert(csp_initialized); assert(data);
/* create blob header */ header = (BLOBHEADER *)G28147_key_blob; header->bType = PLAINTEXTKEYBLOB; header->bVersion = CUR_BLOB_VERSION; header->reserved = 0; header->aiKeyAlg = CALG_G28147; assert(sizeof(*header) == 8);
/* set key length to 32 bytes (= 256 bits) */ G28147_key_blob[8 + 0] = 32; G28147_key_blob[8 + 1] = 0; G28147_key_blob[8 + 2] = 0; G28147_key_blob[8 + 3] = 0;
/* copy key data */ if (length > 32) { length = 32; } memcpy(&G28147_key_blob[8 + 4 + 0], data, length); /* pad with zeros if key is shorter than 32 bytes */ if (length < 32) { memset(&G28147_key_blob[8 + 4 + length], 0, 32 - length); }
rcode = CPCImportKey( crypto_module, crypto_provider, G28147_key_blob, (DWORD)sizeof(G28147_key_blob), 0, CRYPT_EXPORTABLE, key );
if (rcode != S_OK) { /* failure */ set_error(CSP_ERROR_FAILURE, "CPCImportKey: error=0x%x", rcode); return -csp_error.code; }
/* success */ return (0); }
|
|
|
|
Статус: Новичок
Группы: Участники
Зарегистрирован: 03.04.2008(UTC) Сообщений: 9 Откуда: Finland
|
С какими параметрами blob шифруется по умолчанию?
CPCDeriveKey(.., CALG_G28147,"test" CRYPT_EXPORTABLE,internal_session_key);
CPCSetKeyParam(internal_session_key, KP_ALGID, CALG_PRO_EXPORT 0);
CPCGenKey(..., CALG_G28147, CRYPT_EXPORTABLE, &temp_key);
CPCExportKey(..., temp_key, internal_session_key, SIMPLEBLOB, 0, data, &length);
CPCDecrypt(....,internal_session_key, 0, TRUE, 0, data->bEncryptedKey, length );
CPCCreateHash(hash, internal_session_key,) CPCHashData(hash, data->bEncryptedKey) CPCGetHashParam(..., hash, HP_HASHVAL, value, &length, 0);
value != data->bMacKey
Почему hash_value не совпадает с data->bMacKey ?
|
|
|
|
Быстрый переход
Вы не можете создавать новые темы в этом форуме.
Вы не можете отвечать в этом форуме.
Вы не можете удалять Ваши сообщения в этом форуме.
Вы не можете редактировать Ваши сообщения в этом форуме.
Вы не можете создавать опросы в этом форуме.
Вы не можете голосовать в этом форуме.
Important Information:
The Форум КриптоПро uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close