Skip to content

Instantly share code, notes, and snippets.

View dh-recover.js
function recover(privateKey) {
console.log("recover");
const MALICIOUS_PRIME = new Uint8Array([129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17]);
// this generator has order 5
const MALICIOUS_GENERATOR = new Uint8Array([46,35,147,92,93,21,176,170,70,144,93,164,112,85,178,126]);
privateKey.algorithm.generator = MALICIOUS_GENERATOR;
privateKey.algorithm.prime = MALICIOUS_PRIME;
window.crypto.subtle.generateKey(
{
View dh-derivebits.js
/*
* Arguments:
* priv: CryptoKey representing a DH private key
* pub: CryptoKey representing a DH public key
*
* Returns: Promise resolving to ArrayBuffer
*/
async function secret(priv, pub) {
return await window.crypto.subtle.deriveBits(
{
View dh-keypair.js
/*
* Arguments: None
*
* Returns: Promise resolving to:
* {
* privateKey: CryptoKey,
* publicKey: CryptoKey,
* }
*/
View aes-gcm-webcrypto.html
<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){
View aes-gcm-webcrypto.js
//https://github.com/diafygi/webcrypto-examples
window.crypto.subtle.encrypt(
{
name: "AES-GCM",
//Don't re-use initialization vectors!
//Always generate a new iv every time your encrypt!
//Recommended to use 12 bytes length
iv: window.crypto.getRandomValues(new Uint8Array(12)),
View Untitled1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View MSDBRG
package gist;
import java.math.BigInteger;
import java.security.SecureRandom;
public class MSDBRG {
private static BigInteger TWO = new BigInteger("2");
public static void main(String[] args) {
View recovery-code.html
<script>
var ec8fc = {
valueOf: function () {
alert("valueOf1");
return 1;
}
};
var cd0b2 = {
valueOf: function () {
alert("valueOf2");
You can’t perform that action at this time.