Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm371.Button1Click(Sender: TObject);
- var
- KeyArray: TBytes;
- iv: TBytes;
- mmIV: TAESBlock;
- clearText: TBytes;
- aad: TBytes;
- ciphertext: TBytes;
- begin
- KeyArray := [$11, $11, $11, $11, $11, $11, $11, $11, $11, $11, $11, $11, $11, $11, $11, $11];
- iv := [$4D, $45, $54, $00, $00, $00, $00, $01, $00, $00, $00, $00];
- FillChar(mmIv, 16, 0);
- System.Move(iv[0], mmIv, System.Length(iv) );
- cleartext := [$0f, $c0, $00, $00, $01, $0c, $07, $e6, $09, $1a, $01, $03, $27, $2e, $5a, $ff, $88, $80, $02, $02, $09, $06, $00, $01, $19, $09, $00, $ff, $01, $01, $02, $06, $09, $0c, $07, $e6, $09, $1a, $01, $03, $23, $00, $00, $ff, $88, $80, $11, $5a, $17, $49, $cb, $25, $1d, $17, $49, $cb, $25, $1d, $17, $49, $cb, $25, $1d, $17, $49, $cb, $25, $1d];
- aad := [$30, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33, $33];
- setlength(ciphertext, length(cleartext));
- var mAES := TAESGCM.Create(KeyArray);
- mAES.IV := mmIv;
- mAES.Encrypt(nil, nil, 0);
- // Comment / Uncomment for AAD
- // mAES.AesGcmAad(@aad[0], System.Length(aad));
- var rawciphertext := mAES.EncryptPkcs7(Convert(cleartext));
- Move(rawciphertext[1], ciphertext[0], length(rawciphertext));
- var checktag : TAESBlock;
- mAES.AesGcmFinal(checktag);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement