brix / crypto-js

JavaScript library of crypto standards.
Other
15.86k stars 2.39k forks source link

I need aes-gcm in asp #346

Open rimifon opened 3 years ago

rimifon commented 3 years ago

what i can do ?

Hinaser commented 3 years ago

You are so lucky. I'm currently working on implementing AES-GCM and will release after a few hours. https://github.com/Hinaser/jscrypto

Please be patient.

rimifon commented 3 years ago

So lucky!!!

You are so lucky. I'm currently working on implementing AES-GCM and will release after a few hours. https://github.com/Hinaser/jscrypto

Please be patient.

rimifon commented 3 years ago

10 hours left ...

Hinaser commented 3 years ago

Hi I've just released jscrypto 0.2.0, which implements AES-GCM/GMAC! :tada::tada:

Please read README on my repository in order to understand how to use it.

Here is a summary.

AES-GCM

Galois Counter Mode for authenticated encryption.

////////////////////////////////////////////////////////////////////////////////////////
// Authenticated encryption by AES-GCM
////////////////////////////////////////////////////////////////////////////////////////
var key = JsCrypto.Hex.parse("0123456789ABCDEF11113333555577770123456789ABCDEF1111333355557777");
var msg = JsCrypto.Hex.parse("00000000000000000000000000000000");
var iv = JsCrypto.Hex.parse("000000000000000000000000"); // 96bit(12byte) iv is recommended.
var authData = JsCrypto.Utf8.parse("some plain text data for authentication. This will not be encrypted.");

var encryptedData = JsCrypto.AES.encrypt(msg, key, { iv, mode: JsCrypto.mode.GCM, authData });

// Encrypted message
var cipherText = encryptedData.cipherText;
// Authentication Tag
var authTag = encryptedData.authTag;

var decryptedData = JsCrypto.AES.decrypt(encryptedData, key, { iv, mode: JsCrypto.mode.GCM, authData });

// Encrypt/Decrypt as usual
decryptedData.toString() === msg.toString(); // true
// Verify authentication code as well as HMAC
authTag.toString() === JsCrypto.mode.GCM.hash(JsCrypto.AES, key, iv, authData, encryptedData.cipherText).toString(); // true
rimifon commented 3 years ago

How to make it work in ASP or WSF ?

rimifon commented 3 years ago

I can use window.crypto object in bownser. but I expect to use it in ASP. ``