How to use the crypt.GCM function in crypt

To help you get started, we’ve selected a few crypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kinoma / kinomajs / xs6 / extensions / ssl / ssl_setup.js View on Github external
case SSL.cipherSuite.MD5: h = new Crypt.MD5(); break;
		case SSL.cipherSuite.SHA1: h = new Crypt.SHA1(); break;
		case SSL.cipherSuite.SHA256: h = new Crypt.SHA256(); break;
		case SSL.cipherSuite.SHA384: h = new Crypt.SHA384(); break;
		default:
			throw new Error("SSL: SetupCipher: unknown hash algorithm");
		}
		o.hmac = new Crypt.HMAC(h, o.macSecret);
		if (cipher.encryptionMode == SSL.cipherSuite.CBC)
			o.enc = new Crypt.CBC(enc, o.iv);	// no padding -- SSL 3.2 requires padding process beyond RFC2630
		else
			o.enc = enc;
		break;
	case SSL.cipherSuite.GCM:
		let Arith = require.weak("arith");
		o.enc = new Crypt.GCM(enc);
		o.nonce = new Arith.Integer(1);
		break;
	default:
		o.enc = enc;
		break;
	}
}