Last active
September 21, 2024 18:02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program mORMot2_ecc256r1; | |
uses | |
mormot.core.fpcx64mm, | |
mormot.core.os, | |
mormot.core.buffers, | |
mormot.crypt.core, | |
mormot.crypt.ecc256r1, | |
mormot.crypt.ecc; | |
var | |
ClientKeyPair, ServerKeyPair : TEccKeyPair; | |
ClientPubKey : TEccPublicKey; | |
Msg, EncMsg, DecMsg : String; | |
begin | |
Msg := 'Top Secret'; | |
Ecc256r1MakeKey(ClientKeyPair.pub, ClientKeyPair.priv); | |
Ecc256r1MakeKey(ServerKeyPair.pub, ServerKeyPair.priv); | |
WriteLn('Client Pub = ', BinToBase64(@ClientKeyPair.pub[0], SizeOf(TEccPublicKey)) ); | |
WriteLn('Client Priv = ', BinToBase64(@ClientKeyPair.priv[0], SizeOf(TEccPrivateKey)) ); | |
EncMsg := EciesSeal('aes-128-ctr', ServerKeyPair.pub, Msg); | |
WriteLn('Sending Enc Msg to Server'); | |
WriteLn('-----------------------------------------------'); | |
WriteLn('Server Pub = ', BinToBase64(@ServerKeyPair.pub[0], SizeOf(TEccPublicKey)) ); | |
WriteLn('Server Priv = ', BinToBase64(@ServerKeyPair.priv[0], SizeOf(TEccPrivateKey)) ); | |
DecMsg := EciesOpen('aes-128-ctr', ServerKeyPair.priv, EncMsg); | |
WriteLn('Original : ', Msg); | |
WriteLn('Decrypted: ', DecMsg); | |
WriteLn('Done'); | |
ReadLn; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment