MCPcopy Create free account
hub / github.com/apache/cloudstack / _generateKey

Method _generateKey

systemvm/agent/noVNC/core/crypto/rsa.js:39–58  ·  view source on GitHub ↗
(algorithm, extractable)

Source from the content-addressed store, hash-verified

37 }
38
39 async _generateKey(algorithm, extractable) {
40 this._keyLength = algorithm.modulusLength;
41 this._keyBytes = Math.ceil(this._keyLength / 8);
42 const key = await window.crypto.subtle.generateKey(
43 {
44 name: "RSA-OAEP",
45 modulusLength: algorithm.modulusLength,
46 publicExponent: algorithm.publicExponent,
47 hash: {name: "SHA-256"},
48 },
49 true, ["encrypt", "decrypt"]);
50 const privateKey = await window.crypto.subtle.exportKey("jwk", key.privateKey);
51 this._n = this._padArray(this._base64urlDecode(privateKey.n), this._keyBytes);
52 this._nBigInt = u8ArrayToBigInt(this._n);
53 this._e = this._padArray(this._base64urlDecode(privateKey.e), this._keyBytes);
54 this._eBigInt = u8ArrayToBigInt(this._e);
55 this._d = this._padArray(this._base64urlDecode(privateKey.d), this._keyBytes);
56 this._dBigInt = u8ArrayToBigInt(this._d);
57 this._extractable = extractable;
58 }
59
60 static async importKey(key, _algorithm, extractable, keyUsages) {
61 if (keyUsages.length !== 1 || keyUsages[0] !== "encrypt") {

Callers 1

generateKeyMethod · 0.95

Calls 5

_padArrayMethod · 0.95
_base64urlDecodeMethod · 0.95
u8ArrayToBigIntFunction · 0.90
generateKeyMethod · 0.45
exportKeyMethod · 0.45

Tested by

no test coverage detected