3

Windows 10でIE 11を使用してAES-GCMでデータを暗号化できましたが、復号化できません。例えば暗号JSコード:IE 11の結果からデータを解読する方法AES-GCMを使用して暗号化を行う

let plainText = new Uint8Array([1]); 
let key; 
let keyBuf = window.msCrypto.getRandomValues(new Uint8Array(32)); 
let iv = window.msCrypto.getRandomValues(new Uint8Array(12)); 
let additionalData = window.msCrypto.getRandomValues(new Uint8Array(16)); 
let encResult; 
let importOp = window.msCrypto.subtle.importKey('raw', 
    keyBuf, 
    { name: 'AES-GCM' }, 
    false, 
    ['encrypt', 'decrypt']); 
importOp.oncomplete = function(e) { 
    key = e.target.result; 
    let encryptOp = window.msCrypto.subtle.encrypt({ 
     name: 'AES-GCM', 
     iv: iv, 
     tagLength: 128, 
     additionalData: additionalData 
    }, key, plainText); 
    encryptOp.oncomplete = function (e) { 
     encResult = e.target.result; 
    }; 
}; 

得アイテム(encResult)暗号化された値と2つの異なる特性のタグを有するAesGcmEncryptResult、です。私はそれを理解したように、私はこれらを連結し、同様に、復号化するために暗号文として渡す必要があります。

let cipherText = new Uint8Array(plainText.length + 16); // tagLength/8 
cipherText.set(new Uint8Array(encResult.ciphertext), 0); 
cipherText.set(new Uint8Array(encResult.tag), plainText.length); 
let decryptOp = window.msCrypto.subtle.decrypt({ 
    name: 'AES-GCM', 
    iv: iv, 
    tagLength: 128, 
    additionalData: additionalData 
}, key, cipherText); 

私はその後、onCompleteのとONERRORや火災のonErrorアップ配線してください。残念ながら、IEのEventオブジェクトには、type = "error"以外は何も教えてくれません。

が別のブラウザを使用するように私に教えないでくださいIE 11にAES-GCMを使用した上で、Web上ではほとんど情報があります。これはすべてChromeとFirefoxでうまく機能します(ただし違う)。私は具体的にIE 11でこれを動作させようとしています。

私は何が欠けていますか?

答えて

3

これは、(曖昧に)タグ値がアルゴリズムオブジェクトに入り、暗号テキストだけが第3引数に入ることを示しています(shim)。例えば。

let decryptOp = window.msCrypto.subtle.decrypt({ 
    name: 'AES-GCM', 
    iv: iv, 
    additionalData: additionalData, 
    tag: new Uint8Array(encResult.tag) 
    }, key, new Uint8Array(encResult.ciphertext)); 

なぜこれは見つけにくいのですか?この機能についてのブログ投稿がないのはなぜですか?なぜMSのドキュメントは細かいところで短いのですか?

関連する問題