| ||||
| ||||
Я вот хочу сделать Export ключа. ExpSessionKey(const aName: string; var apKey: Pbyte; var aikey: Integer; var aError: string): Boolean; var hProvider: WCrypt2.HCRYPTPROV; hKey: WCrypt2.HCRYPTKEY; DataSize: Integer; begin { 0 } Result := FALSE; { Create CSP handle } if (not WCrypt2.CryptAcquireContext(@hProvider, PChar(aName), nil, 75, 0)) then begin { 0 } aError := GetErrorDescription(Windows.GetLastError()); System.Exit; end; { :0 } if not CryptGetUserKey(hProvider, AT_SIGNATURE, @hKey) then begin aError := ’zxcvzxczx 1: ’ + GetErrorDescription(Windows.GetLastError()); Result := false; WCrypt2.CryptReleaseContext(hProvider, 0); System.Exit; end; { Get key size } if (not WCrypt2.CryptExportKey(hKey, 0, WCrypt2.PUBLICKEYBLOB, 0, nil, @aiKey)) then begin { 0 } aError := GetErrorDescription(Windows.GetLastError()); { Release handles } WCrypt2.CryptDestroyKey(hKey); WCrypt2.CryptReleaseContext(hProvider, 0); System.Exit; end; { :0 } System.GetMem(apKey, aiKey); { Export key } if (not WCrypt2.CryptExportKey(hKey, 0, WCrypt2.PUBLICKEYBLOB, 0, apKey, @aiKey)) then begin { 0 } aError := GetErrorDescription(Windows.GetLastError()); { Release handles } WCrypt2.CryptDestroyKey(hKey); WCrypt2.CryptReleaseContext(hProvider, 0); System.FreeMem(apKey); apKey := nil; aiKey := 0; System.Exit; end; { :0 } { Release handles } WCrypt2.CryptDestroyKey(hKey); WCrypt2.CryptReleaseContext(hProvider, 0); Result := TRUE; // // end; Что я делаю неверно он (ключ) выходит кривой :((( | ||||
Ответы: | ||||
| ||||
Я разобрался. | ||||