Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- key, iv, aad, ocipher, cipher, uncipher, cleartext: RawByteString;
- aes: TAesGcmAbstract;
- tag: THash128;
- dummy: THash256;
- same: boolean;
- begin
- key := hextobin('11111111111111111111111111111111');
- iv := hextobin('4D4554000000000100000000');
- aad := hextobin('3033333333333333333333333333333333');
- cleartext := hextobin('0fc00000010c07e6091a0103272e5aff8880020209060001190900ff01010206090c07e6091a0103230000ff8880115a1749cb251d1749cb251d1749cb251d1749cb251d');
- var tmp := hextobin('e9ceff7675f00b0e217b7620');
- FillZero(tag);
- aes := TAesGcm.Create(pointer(key)^, 128);
- try
- aes.IV := PHash128(iv)^;
- aes.MacSetNonce(false, dummy, aad);
- cipher := aes.EncryptPkcs7(cleartext);
- aes.AesGcmFinal(tag);
- // here (tag = tmp) -> FALSE in both Win64 and Win32
- finally
- aes.Free;
- end;
- FillZero(tag);
- aes := TAesGcm.Create(pointer(key)^, 128);
- try
- aes.IV := PHash128(iv)^;
- aes.MacSetNonce(true, dummy, aad);
- aes.Encrypt(pointer(cleartext), pointer(cipher), 68);
- aes.AesGcmFinal(tag);
- // here (tag = tmp) -> FALSE in Win32
- finally
- aes.Free;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement