Skip to content

Instantly share code, notes, and snippets.

@asanso
Last active January 7, 2020 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asanso/c68182d7c1e97db2f5c2b7c80c59fd54 to your computer and use it in GitHub Desktop.
Save asanso/c68182d7c1e97db2f5c2b7c80c59fd54 to your computer and use it in GitHub Desktop.
<script>
window.crypto.subtle.generateKey(
{
name: "AES-GCM",
length: 256, //can be 128, 192, or 256
},
false, //whether the key is extractable (i.e. can be used in exportKey)
["encrypt", "decrypt"] //can "encrypt", "decrypt", "wrapKey", or "unwrapKey"
)
.then(function(key){
//returns a key object
console.log(key);
})
.catch(function(err){
console.error(err);
});
</script>
<script>
//XSS here
window.crypto.subtle.exportKey(
"jwk", //can be "jwk" or "raw"
key //extractable must be true
)
.then(function(keydata){
//returns the exported key data
console.log(keydata);
})
.catch(function(err){
console.error(err);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment