You are not logged in.
Pages: 1
Hi.
I can't find a way for signing a file with mormot.
I search forum and googled and can't find anything about that.
Offline
Result is empty string:
key = '-----BEGIN RSA PRIVATE KEY----- ...'
var pub := TCryptPublicKeyEcc.Create;
pub.Load(ckaEcc256, Memo2.Lines.Text);
var key := TCryptPrivateKeyEcc.Create;
key.Load(ckaEcc256,pub,Memo1.Lines.Text,'');
var s := key.Sign(caaRS256,'1'); // s = ''
Offline
when I set ckaRsa : key.Load(ckaRsa,pub,Memo1.Lines.Text,'');
erorr : TCryptPublicKeyEcc.Create: unsupported ckaNone
I debuged it little bit in TCryptPublicKeyEcc.Load function only ckaEcc256 supported.
Last edited by anouri (2025-02-02 10:18:38)
Offline
There is no mormot.core.rsa but mormot.crypt.rsa was in uses clause.
Offline
I am trying to use
OpenSslSign('',pointer(msg),pointer(priv),Length(msg),Length(priv),sig)
raise Access violation in mormot.crypt.openssl
function :
function BIO_new_mem_buf(buf: pointer; len: integer): PBIO;
Last edited by anouri (2025-02-02 13:56:35)
Offline
This one works.
I don't know is it right or not.
RegisterOpenSsl;
var aa := CryptAsymOpenSsl[caaPS512].Create('secp256r1');
//secp192r1 ,secp224r1 ,secp256r1 = prime256v1 ,secp384r1 ,secp521r1 , brainpoolP256r1 ,brainpoolP384r1 ,brainpoolP512r1
var prv,pub: RawUtf8;
prv := Memo1.Lines.Text;
aa.Sign(msg,prv,sig);
pub := Memo2.Lines.Text;
if aa.Verify(msg,pub,sig) then
ShowMessage('verified');
Last edited by anouri (2025-02-02 16:20:04)
Offline
Hi.
I got abstract error in Generate:
var
LICryptPrivateKey: ICryptPrivateKey;
begin
LICryptPrivateKey := TCryptPrivateKey.Create;
TCryptPrivateKey(LICryptPrivateKey).Generate(caaRS256);
Offline
Thank you so much.
solved ❤️
Offline
I have another problem. This code does not generate correct result for unicode characters. for ansi chars it is ok.
Seems I have problem converting string to rawbytestring?
var CryptPrivateKeyRsa := TCryptPrivateKeyRsa.Create;
CryptPrivateKeyRsa.Load(ckaRsa, nil,Memo1.Lines.Text,'');
var msg: RawByteString;
msg := Edit1.Text;
//var sig := CryptPrivateKeyRsa.Sign(caaRS256,msg);
var sig := CryptPrivateKeyRsa.Sign(caaRS256,pointer(msg),Length(msg));
var sig64:= BinToBase64(sig);
Memo3.Lines.Text := sig64;
Offline
Sorry for the stupid question.
Using StringToUtf8 solved the problem:
msg := StringToUtf8(Edit1.Text);
Last edited by anouri (2025-02-05 11:23:07)
Offline
Pages: 1