mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-12 09:49:11 +02:00
fcl-hash: added rsa test
This commit is contained in:
parent
60c967f255
commit
7664b32e5f
@ -5,7 +5,7 @@ unit utestpem;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testregistry, fpasn, fppem;
|
||||
Classes, SysUtils, fpcunit, testregistry, fpasn, fppem, fprsa;
|
||||
|
||||
Type
|
||||
|
||||
@ -14,13 +14,13 @@ Type
|
||||
TTestPEM = Class(TTestCase)
|
||||
Published
|
||||
Procedure TestLoad;
|
||||
Procedure TestRSA_RS256Verify;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses basenenc, fphashutils, fpecc;
|
||||
|
||||
|
||||
{ TTestPEM }
|
||||
Const
|
||||
PrivateKeyFile = 'private-key.pem';
|
||||
@ -55,7 +55,7 @@ begin
|
||||
try
|
||||
Res:=FileExists(PrivateKeyFile) and PemIsECDSA(PrivateKeyFile, List);
|
||||
if Res then
|
||||
PemLoadPublicKey64FromList(List, PrivateKey, PublicKey, PublicKeyX64, PublicKeyY64);
|
||||
PemLoadPublicKey64FromList(List, PrivateKey, PublicKey, PublicKeyX64, PublicKeyY64);
|
||||
AssertEquals('Private key',resprivatekey,BytesToHexStr(BytesFromVar(@PrivateKey,Sizeof(PrivateKey))));
|
||||
AssertEquals('Public key',respublickey,BytesToHexStr(BytesFromVar(@PublicKey,Sizeof(PublicKey))));
|
||||
AssertEquals('X',resX,PublicKeyX64);
|
||||
@ -71,6 +71,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestPEM.TestRSA_RS256Verify;
|
||||
begin
|
||||
if not fprsa.TestRS256Verify then
|
||||
Fail('TestRS256Verify');
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterTest(TTestPEM);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user