(spk)
| 104 | } |
| 105 | }, |
| 106 | decodeSPKI(spk) { |
| 107 | spk = this.getSPK(spk); |
| 108 | if (!spk) |
| 109 | throw new Error("x509: bad SPKI"); |
| 110 | |
| 111 | let ber; |
| 112 | switch (spk.algo.toString()) { |
| 113 | case "1,2,840,113549,1,1,1": |
| 114 | case "1,3,14,3,2,11": |
| 115 | case "2,5,8,1,1": { |
| 116 | // PKCS1 |
| 117 | ber = new BER(spk); |
| 118 | if (ber.getTag() !== 0x30) |
| 119 | throw new Error("x509: bad SPKI"); |
| 120 | ber.getLength(); |
| 121 | return { |
| 122 | modulus: ber.getInteger(), |
| 123 | exponent: ber.getInteger(), |
| 124 | algo: spk.algo, |
| 125 | }; |
| 126 | } |
| 127 | case "1,2,840,10045,2,1": { |
| 128 | // ecPublicKey |
| 129 | if (!spk.param) |
| 130 | throw new Error("x509: support named curves only for now"); |
| 131 | ber = new BER(spk.param); |
| 132 | switch (ber.getObjectIdentifier().toString()) { |
| 133 | case "1,2,840,10045,3,1,7": // secp256r1 |
| 134 | return { |
| 135 | curve: new Curve("secp256r1"), |
| 136 | pub: ECPoint.fromOctetString(spk), |
| 137 | algo: spk.algo, |
| 138 | }; |
| 139 | case "1,3,132,0,34": // secp384r1 http://www.secg.org/sec2-v2.pdf |
| 140 | return { |
| 141 | curve: new Curve("secp384r1"), |
| 142 | pub: ECPoint.fromOctetString(spk), |
| 143 | algo: spk.algo, |
| 144 | }; |
| 145 | default: |
| 146 | throw new Error("x509: unsupported curve"); |
| 147 | } |
| 148 | } |
| 149 | default: |
| 150 | trace("x509: " + spk.algo + " not supported\n"); |
| 151 | return {}; |
| 152 | } |
| 153 | throw new Error("x509: bad SPKI"); |
| 154 | }, |
| 155 | decodeSKI(buf) { |
| 156 | let ski = this.decodeExtension(buf, [2, 5, 29, 14]); |
| 157 | if (ski) { |
no test coverage detected