Skip to content

Instantly share code, notes, and snippets.

@jaytaph
Created October 22, 2013 10:26
Show Gist options
  • Save jaytaph/7098321 to your computer and use it in GitHub Desktop.
Save jaytaph/7098321 to your computer and use it in GitHub Desktop.
// 7. Create sig
// This is why we can't have nice things
if (! defined('OPENSSL_ALGO_SHA256')) define('OPENSSL_ALGO_SHA256', 7);
// // sign & encrypt the sig
// var md = forge.md.sha256.create();
// md.update(body.bytes());
// var sig = id.private.sign(md);
openssl_sign($body, $sig, $my_priv_key, OPENSSL_ALGO_SHA256);
// var md = forge.md.sha256.create();
// md.update(to.ecc.public.uncompressed);
// md.update(forge.util.hexToBytes(to.lineOut));
$ctx = hash_init('sha256');
hash_update($ctx, $ecc->pubkey);
hash_update($ctx, hex2bin($to->line));
$aes_key = hash_final($ctx, true);
// var cipher = forge.aes.createEncryptionCipher(md.digest(), "CTR");
// cipher.start(iv);
// cipher.update(forge.util.createBuffer(sig));
// cipher.finish();
$cipher = new \Crypt_AES(CRYPT_AES_MODE_CTR);
$cipher->setIv($iv);
$cipher->setKey($aes_key);
$aes = $cipher->encrypt($sig);
// open.sig = forge.util.encode64(cipher.output.bytes());
$sig = base64_encode($aes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment