Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2006.06.25;
Скачать: [xml.tar.bz2];

Вниз

Установка криптопровайдеров   Найти похожие ветки 

 
Eraser ©   (2006-03-24 22:59) [0]

Доброе время суток.
Возник тут вопрос. Можно ли установить стандартные криптопровайдеры от MS, например Microsoft Enhanced RSA and AES Cryptographic Provider, на систему где этого провайдера нету, например Win9x, не устанавливая IE6.


 
Rouse_ ©   (2006-03-26 00:18) [1]

На сколько мне известно нет... А что за задача стоит? Просто судя по вопросу, ты столкнулся с одной из проблем, которая стоит передо мной и все еще не решена...


 
Eraser ©   (2006-03-26 13:27) [2]


> Rouse_ ©   (26.03.06 00:18) [1]


> А что за задача стоит?

Задача - использовать алгоритм AES средствами CryptoAPI...  я даже не уверен, что он в 2K установлен по-умолчанию...
более того скорее всего пригодится Microsoft Enhanced Cryptographic Provider, про который ясно написано в MSDN, что он не поддерживается в win9x (

Бог с ним даже с симметричным шифрованием, LockBox применял и дальше спокойно применять буду, но вот скорость генерации ассиметричных ключей RSA удручает, если CryptoAPI генерирует 1024 битный ключ меньше секунды, то LockBox - около 30 секунд.. а это никуда не годится.

Возможно для аутентификации буду применять алгоритм Diffie-Hellman"а, который очевидно находится в криптопровайдере Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider или Microsoft Base DSS and Diffie-Hellman Cryptographic Provider .. в win9x этих провайдеров нету...

PS Если у кого есть примеры использования алгоритма Diffie-Hellman"а на CryptoAPI - поделитесь пожалуйса... не важно на какой языке программирования.


 
Reindeer Moss Eater ©   (2006-03-26 16:15) [3]

DH это не алгоритм кодирования.
Это алгоритм обмена ключами. Его не может не быть в 9x


 
Eraser ©   (2006-03-26 17:19) [4]


> Reindeer Moss Eater ©   (26.03.06 16:15) [3]

да я вкурсе что это алгорит обмена ключами, я имел ввиду есть ли под win9x реализация этого алгоритма в CryptoAPI, т.е. Algid = CALG_DH_EPHEM или CALG_DH_SF?


 
Reindeer Moss Eater ©   (2006-03-26 18:12) [5]

Так попробуй использовать их с конкретным провайдером.


 
Eraser ©   (2006-03-26 18:33) [6]


> Reindeer Moss Eater ©   (26.03.06 18:12) [5]

так ... сейчас скопировал с локалки установленый образ VMWare с win98 - там имеются следующие криптопровайдеры:
Microsoft Base Cryptographic Provider v1.0
Microsoft Base DSS Cryptographic Provider
и  Microsoft Base DSS and Diffie-Hellman Cryptographic Provider
правда на этой VM установлен RAdmin 2.1 и WinGate.
Версия IE 4.72.3110.4 SP1

У кого есть Win9x или NT4 (желательно 95), если не составит большого труда, пожалуйста, дайте список установленных криптопровайдеров.
Получить этот список можно с пом. не хитрой программки
вот исходники на Делфи http://webfile.ru/878910 (65 KB)
(выбрать меню Сервис->Информация об установленных криптопровайдерах)


 
Rouse_ ©   (2006-03-27 12:55) [7]

Чистый 98 SE, стоит разве что седьмая Дельфи

Криптопровайдер: Microsoft Base DSS Cryptographic Provider
Тип: 3 - DSS provider
Версия: 1.0
Тип реализации: программный
Поддерживает алгоритмы:
SHA1 длина ключа - 160 бит ID: 32772
MD5 длина ключа - 128 бит ID: 32771
DSA_SIGN длина ключа - 1024 бит ID: 8704

Криптопровайдер: Microsoft Base DSS and Diffie-Hellman Cryptographic Provider
Тип: 13 - DSS and Diffie-Hellman provider
Версия: 1.0
Тип реализации: программный
Поддерживает алгоритмы:
CYLINK MEK длина ключа - 40 бит ID: 26124
RC2 длина ключа - 40 бит ID: 26114
RC4 длина ключа - 40 бит ID: 26625
SHA1 длина ключа - 160 бит ID: 32772
MD5 длина ключа - 128 бит ID: 32771
DSA_SIGN длина ключа - 1024 бит ID: 8704
DH_KEYX длина ключа - 512 бит ID: 43521

Криптопровайдер: Microsoft Base Cryptographic Provider v1.0
Тип: 1 - RSA full provider
Версия: 2.0
Тип реализации: программный
Поддерживает алгоритмы:
RC2 длина ключа - 40 бит ID: 26114
RC4 длина ключа - 40 бит ID: 26625
SHA-1 длина ключа - 160 бит ID: 32772
MD2 длина ключа - 128 бит ID: 32769
MD4 длина ключа - 128 бит ID: 32770
MD5 длина ключа - 128 бит ID: 32771
SSL3 SHAMD5 длина ключа - 288 бит ID: 32776
MAC длина ключа - 64 бит ID: 32773
RSA_SIGN длина ключа - 512 бит ID: 9216
RSA_KEYX длина ключа - 512 бит ID: 41984
HMAC длина ключа - 0 бит ID: 32777


 
Eraser ©   (2006-03-27 13:24) [8]


> Rouse_ ©   (27.03.06 12:55) [7]

аналогично )
Спасибо.

К слову вчера потратил вечер и перевёл таки пример использования Diffie-Hellman"a из MSDN (C++) на Delphi.
Правда с несколькими улучшениями )
Если в примере от MS используются "прегенерированные" значения P и G, то в своём примере одна сторона генерирует эти значения случайным образом и передаёт другой стороне.

Вот исходный пример на C++
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/security/diffie_hellman_keys.asp

Мой пример иожно скачать тут http://webfile.ru/880164
Вот основная часть:


 
Eraser ©   (2006-03-27 13:25) [9]


procedure DebugOut(const AText: string);
begin
 ShowMessage(AText);
end;

procedure DiffieHellmanTest(AData: TMemoryStream);
const
 DHKEYSIZE = 512;
 MS_ENH_DSS_DH_PROV = "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider";
var
 hProvParty1, hProvParty2,
 hPublicKey1, hPublicKey2,
 hSessionKey1, hSessionKey2: THandle;
 dwDataLen1, dwDataLen2: DWORD;
 pbKeyBlob1, pbKeyBlob2, pData: PByte;
 dwLength: DWORD;
 bReturn: Boolean;
 Algid: ALG_ID;
 P, G: DATA_BLOB;
begin
 hProvParty1 := 0;
 hProvParty2 := 0;
 hPublicKey1 := 0;
 hPublicKey2 := 0;
 hSessionKey1 := 0;
 hSessionKey2 := 0;
 pbKeyBlob1 := nil;
 pbKeyBlob2 := nil;
 pData := nil;
 Algid := CALG_RC4;
 P.pbData := nil;
 G.pbData := nil;
 try
   // *****
   // Create an ephemeral public key for party 1.
   bReturn := CryptAcquireContext(@hProvParty1, nil,
     MS_ENH_DSS_DH_PROV,
     //MS_DEF_DSS_DH_PROV, we can use Base provider
     PROV_DSS_DH, CRYPT_VERIFYCONTEXT);
   if not bReturn then
   begin
     DebugOut("CryptAcquireContext - Error1");
     Exit;
   end;
   bReturn := CryptGenKey(hProvParty1, CALG_DH_EPHEM,
     (DHKEYSIZE shl 16) or CRYPT_EXPORTABLE, @hPublicKey1);
   if not bReturn then
   begin
     DebugOut("CryptGenKey - Error1");
     Exit;
   end;
   // *****
   // Get the prime of party 1"s public key.
   // Calc size.
   dwLength := 0;
   bReturn := CryptGetKeyParam(hPublicKey1, KP_P, nil, @dwLength, 0);
   if not bReturn then
   begin
     DebugOut("CryptGetKeyParam ("P" - size) - Error");
     Exit;
   end;
   P.cbData := dwLength;
   GetMem(P.pbData, dwLength);
   // Get prime P.
   bReturn := CryptGetKeyParam(hPublicKey1, KP_P, P.pbData, @dwLength, 0);
   if not bReturn then
   begin
     DebugOut("CryptGetKeyParam (Get "P") - Error");
     Exit;
   end;
   // Get the generator for party 1"s private key.
   // Calc size.
   dwLength := 0;
   bReturn := CryptGetKeyParam(hPublicKey1, KP_G, nil, @dwLength, 0);
   if not bReturn then
   begin
     DebugOut("CryptGetKeyParam ("G" - size) - Error");
     Exit;
   end;
   G.cbData := dwLength;
   GetMem(G.pbData, dwLength);
   // Get generator G.
   bReturn := CryptGetKeyParam(hPublicKey1, KP_G, G.pbData, @dwLength, 0);
   if not bReturn then
   begin
     DebugOut("CryptGetKeyParam (Get "G") - Error");
     Exit;
   end;    
   // *****
   // Create an ephemeral public key for party 2.
   bReturn := CryptAcquireContext(@hProvParty2, nil,
     MS_ENH_DSS_DH_PROV,
     //MS_DEF_DSS_DH_PROV, we can use Base provider
     PROV_DSS_DH, CRYPT_VERIFYCONTEXT);
   if not bReturn then
   begin
     DebugOut("CryptAcquireContext - Error2");
     Exit;
   end;
   bReturn := CryptGenKey(hProvParty2, CALG_DH_EPHEM,
     (DHKEYSIZE shl 16) or CRYPT_EXPORTABLE, @hPublicKey2);
   if not bReturn then
   begin
     DebugOut("CryptGenKey - Error2");
     Exit;
   end;
   // *****
   // Set the prime for party 2"s public key.
   bReturn := CryptSetKeyParam(hPublicKey2, KP_P, @P, 0);
   if not bReturn then
   begin
     DebugOut("CryptSetKeyParam ("P") - Error");
     Exit;
   end;
   // Set the generator for party 2"s public key.
   bReturn := CryptSetKeyParam(hPublicKey2, KP_G, @G, 0);
   if not bReturn then
   begin
     DebugOut("CryptSetKeyParam ("G") - Error");
     Exit;
   end;
   // Generate the secret values for party 2"s public key.
   bReturn := CryptSetKeyParam(hPublicKey2, KP_X, nil, 0);
   if not bReturn then
   begin
     DebugOut("CryptSetKeyParam ("X") - Error2");
     Exit;
   end;
   // Export Party 1"s public key.
   // Get the size for the key BLOB.
   bReturn := CryptExportKey(hPublicKey1, 0, PUBLICKEYBLOB,
     0, nil, @dwDataLen1);
   if not bReturn then
   begin
     DebugOut("CryptExportKey (size calc) - Error1");
     Exit;
   end;
   // Allocate the memory for the key BLOB.
   GetMem(pbKeyBlob1, dwDataLen1);
   // Get the key BLOB.
   bReturn := CryptExportKey(hPublicKey1, 0, PUBLICKEYBLOB,
     0, pbKeyBlob1, @dwDataLen1);
   if not bReturn then
   begin
     DebugOut("CryptExportKey - Error1");
     Exit;
   end;
   // Export Party 2"s public key.
   // Get the size for the key BLOB.
   bReturn := CryptExportKey(hPublicKey2, 0, PUBLICKEYBLOB,
     0, nil, @dwDataLen2);
   if not bReturn then
   begin
     DebugOut("CryptExportKey (size calc) - Error2");
     Exit;
   end;
   // Allocate the memory for the key BLOB.
   GetMem(pbKeyBlob2, dwDataLen2);
   // Get the key BLOB.
   bReturn := CryptExportKey(hPublicKey2, 0, PUBLICKEYBLOB,
     0, pbKeyBlob2, @dwDataLen2);
   if not bReturn then
   begin
     DebugOut("CryptExportKey - Error2");
     Exit;
   end;


 
Eraser ©   (2006-03-27 13:25) [10]


   // *****
   // Party 1 imports party 2"s public key.
   // The imported key will contain the new shared secret
   bReturn := CryptImportKey(hProvParty1, pbKeyBlob2, dwDataLen2,
     hPublicKey1, 0, @hSessionKey2);
   if not bReturn then
   begin
     DebugOut("CryptImportKey - Error1");
     Exit;
   end;
   // Party 2 imports party 1"s public key.
   // The imported key will contain the new shared secret
   bReturn := CryptImportKey(hProvParty2, pbKeyBlob1, dwDataLen1,
     hPublicKey2, 0, @hSessionKey1);
   if not bReturn then
   begin
     DebugOut("CryptImportKey - Error2");
     Exit;
   end;
   // *****
   // Convert the agreed keys to symmetric keys. They are currently of
   // the form CALG_AGREEDKEY_ANY. Convert them to CALG_RC4.
   // Enable the party 1 public session key for use by setting the ALGID.
   bReturn := CryptSetKeyParam(hSessionKey1, KP_ALGID, @Algid, 0);
   if not bReturn then
   begin
     DebugOut("CryptSetKeyParam - Error1");
     Exit;
   end;
   // Enable the party 2 public session key for use by setting the ALGID.
   bReturn := CryptSetKeyParam(hSessionKey2, KP_ALGID, @Algid, 0);
   if not bReturn then
   begin
     DebugOut("CryptSetKeyParam - Error2");
     Exit;
   end;
   // *****
   // Encrypt some data with party 1"s session key.
   dwLength := AData.Size;
   // Get the size.
   bReturn := CryptEncrypt(hSessionKey1, 0, true, 0, nil, @dwLength,
     AData.Size);
   if not bReturn then
   begin
     DebugOut("CryptEncrypt (get size) - Error");
     Exit;
   end;
   // Allocate a buffer to hold the encrypted data.
   GetMem(pData, dwLength);
   // Copy the unencrypted data to the buffer. The data will be
   // encrypted in place.
   AData.Read(pData^, AData.Size);
   dwLength := AData.Size;
   // Encrypt the data.
   bReturn := CryptEncrypt(hSessionKey1, 0, true, 0, pData, @dwLength,
     AData.Size);
   if not bReturn then
   begin
     DebugOut("CryptEncrypt - Error");
     Exit;
   end;
   // ***** !!!!!!!!!!
   AData.Clear;
   // ***** !!!!!!!!!!
   // Decrypt the data with party 2"s session key.
   bReturn := CryptDecrypt(hSessionKey2, 0, true, 0, pData, @dwLength);
   if not bReturn then
   begin
     DebugOut("CryptDecrypt - Error");
     Exit;
   end;
   AData.Write(pData^, dwLength);
   AData.Position := 0;
 finally
   if Assigned(pData) then
     FreeMem(pData);
   if hSessionKey2 <> 0 then
     CryptDestroyKey(hSessionKey2);
   if hSessionKey1 <> 0 then
     CryptDestroyKey(hSessionKey1);
   if Assigned(pbKeyBlob2) then
     FreeMem(pbKeyBlob2);
   if Assigned(pbKeyBlob1) then
     FreeMem(pbKeyBlob1);
   if hPublicKey2 <> 0 then
     CryptDestroyKey(hPublicKey2);
   if hPublicKey1 <> 0 then
     CryptDestroyKey(hPublicKey1);
   if hProvParty2 <> 0 then
     CryptReleaseContext(hProvParty2, 0);
   if hProvParty1 <> 0 then
     CryptReleaseContext(hProvParty1, 0);
   if Assigned(P.pbData) then
     FreeMem(P.pbData);
   if Assigned(G.pbData) then
     FreeMem(G.pbData);
 end;
end;


 
Eraser ©   (2006-03-28 15:32) [11]

А какие криптопровайдеры в Win2K без сервиспаков по-умолчанию установлены?



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2006.06.25;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.5 MB
Время: 0.01 c
15-1148799929
Ega23
2006-05-28 11:05
2006.06.25
&amp;#209; &amp;#196;&amp;#237;ё&amp;#236; &amp;#240;&amp;#238;&amp;#230;&amp;#228;&amp;#229;&amp;#237;&amp;#232;&amp;#255;! 28 мая


6-1125580152
Gold
2005-09-01 17:09
2006.06.25
IdPOP31.Retrieve(i,IdMessage1) - coding table entry not found


2-1149598657
XTD
2006-06-06 16:57
2006.06.25
как в листбоксе выделить позиции в списке ?


10-1121170006
SergP.
2005-07-12 16:06
2006.06.25
Работа с COM-объектом (EXCEL, WORD) из консольного приложения


2-1149447737
Ray
2006-06-04 23:02
2006.06.25
свернуть модальную форму





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский