|
| 1 | +declare module 'jsrsasign' { |
| 2 | + class KEYUTIL { |
| 3 | + static getKey(param: string, passcode?: string, hextype?: string): any |
| 4 | + |
| 5 | + static getJWKFromKey(keyObj: any): any |
| 6 | + } |
| 7 | + |
| 8 | + class X509 { |
| 9 | + /** |
| 10 | + * Get format version (X.509v1 or v3 certificate). |
| 11 | + * |
| 12 | + * @return 1 for X509v1, 3 for X509v3, otherwise 0 |
| 13 | + */ |
| 14 | + getVersion(): string |
| 15 | + |
| 16 | + /** |
| 17 | + * Get hexadecimal string of serialNumber field of certificate. |
| 18 | + * |
| 19 | + * @return hexadecimal string of certificate serial number |
| 20 | + */ |
| 21 | + getSerialNumberHex(): string |
| 22 | + |
| 23 | + /** |
| 24 | + * Get signature algorithm name in basic field |
| 25 | + * |
| 26 | + * @return signature algorithm name (ex. SHA1withRSA, SHA256withECDSA) |
| 27 | + */ |
| 28 | + getSignatureAlgorithmField(): string |
| 29 | + |
| 30 | + /** |
| 31 | + * Get hexadecimal string of issuer field TLV of certificate. |
| 32 | + * |
| 33 | + * @return hexadecial string of issuer DN ASN.1 |
| 34 | + */ |
| 35 | + getIssuerHex(): string |
| 36 | + |
| 37 | + /** |
| 38 | + * Get string of issuer field of certificate. |
| 39 | + * |
| 40 | + * @return issuer DN string |
| 41 | + */ |
| 42 | + getIssuerString(): string |
| 43 | + |
| 44 | + /** |
| 45 | + * Get hexadecimal string of subject field of certificate. |
| 46 | + * |
| 47 | + * @return hexadecial string of subject DN ASN.1 |
| 48 | + */ |
| 49 | + getSubjectHex(): string |
| 50 | + |
| 51 | + /** |
| 52 | + * Get string of subject field of certificate. |
| 53 | + * |
| 54 | + * @return subject DN string |
| 55 | + */ |
| 56 | + getSubjectString(): string |
| 57 | + |
| 58 | + /** |
| 59 | + * Get notBefore field string of certificate. |
| 60 | + * |
| 61 | + * @return not before time value (ex. "151231235959Z") |
| 62 | + */ |
| 63 | + getNotBefore(): string |
| 64 | + |
| 65 | + /** |
| 66 | + * Get notAfter field string of certificate. |
| 67 | + * |
| 68 | + * @return not after time value (ex. "151231235959Z") |
| 69 | + */ |
| 70 | + getNotAfter(): string |
| 71 | + |
| 72 | + /** |
| 73 | + * Get a hexadecimal string of subjectPublicKeyInfo field. |
| 74 | + * |
| 75 | + * @return ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field |
| 76 | + */ |
| 77 | + getPublicKeyHex(): string |
| 78 | + |
| 79 | + /** |
| 80 | + * Get a string index of subjectPublicKeyInfo field for hexadecimal string certificate. |
| 81 | + * |
| 82 | + * @return string index of subjectPublicKeyInfo field for hexadecimal string certificate. |
| 83 | + */ |
| 84 | + getPublicKeyIdx(): number |
| 85 | + |
| 86 | + /** |
| 87 | + * Get a string index of contents of subjectPublicKeyInfo BITSTRING value from hexadecimal certificate. |
| 88 | + * |
| 89 | + * @return string index of key contents |
| 90 | + */ |
| 91 | + getPublicKeyContentIdx(): number |
| 92 | + |
| 93 | + // /** |
| 94 | + // * Get a RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field. |
| 95 | + // * |
| 96 | + // * @return RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field |
| 97 | + // */ |
| 98 | + // getPublicKey() |
| 99 | + |
| 100 | + /** |
| 101 | + * Get signature algorithm name from hexadecimal certificate data. |
| 102 | + * |
| 103 | + * @return signature algorithm name (ex. SHA1withRSA, SHA256withECDSA) |
| 104 | + */ |
| 105 | + getSignatureAlgorithmName(): string |
| 106 | + |
| 107 | + /** |
| 108 | + * Get signature value in hexadecimal string. |
| 109 | + * |
| 110 | + * @return signature value hexadecimal string without BitString unused bits |
| 111 | + */ |
| 112 | + getSignatureValueHex(): string |
| 113 | + |
| 114 | + // /** |
| 115 | + // * Verifies signature value by public key. |
| 116 | + // * |
| 117 | + // * @param pubKey public key object |
| 118 | + // * |
| 119 | + // * @return true if signature value is valid otherwise false |
| 120 | + // */ |
| 121 | + // verifySignature(pubKey): boolean |
| 122 | + |
| 123 | + /** |
| 124 | + * Set array of X.509v3 extesion information such as extension OID, criticality and value index. |
| 125 | + */ |
| 126 | + parseExt(): void |
| 127 | + |
| 128 | + /** |
| 129 | + * @param oidOrName X.509 extension oid or name (ex. keyUsage or 2.5.29.19) |
| 130 | + * |
| 131 | + * @return X.509 extension information such as extension OID or value index |
| 132 | + */ |
| 133 | + getExtInfo(oidOrName: string): { oid: string, critical: boolean, vidx: number } |
| 134 | + |
| 135 | + /** |
| 136 | + * Get BasicConstraints extension value as object in the certificate. |
| 137 | + * |
| 138 | + * @return associative array which may have "cA" and "pathLen" parameters |
| 139 | + */ |
| 140 | + getExtBasicConstraints(): { cA: boolean, pathLen: number } |
| 141 | + |
| 142 | + /** |
| 143 | + * Get KeyUsage extension value as binary string in the certificate. |
| 144 | + * |
| 145 | + * @return binary string of key usage bits (ex. '101') |
| 146 | + */ |
| 147 | + getExtKeyUsageBin(): string |
| 148 | + |
| 149 | + /** |
| 150 | + * Get KeyUsage extension value as names in the certificate. |
| 151 | + * |
| 152 | + * @return comma separated string of key usage |
| 153 | + */ |
| 154 | + getExtKeyUsageString(): string |
| 155 | + |
| 156 | + /** |
| 157 | + * Get subjectKeyIdentifier value as hexadecimal string in the certificate. |
| 158 | + * |
| 159 | + * @return hexadecimal string of subject key identifier or null |
| 160 | + */ |
| 161 | + getExtSubjectKeyIdentifier(): string | null |
| 162 | + |
| 163 | + /** |
| 164 | + * Get authorityKeyIdentifier value as JSON object in the certificate. |
| 165 | + * |
| 166 | + * @return JSON object of authority key identifier or null |
| 167 | + */ |
| 168 | + getExtAuthorityKeyIdentifier(): { kid: string } | null |
| 169 | + |
| 170 | + /** |
| 171 | + * Get extKeyUsage value as array of name string in the certificate. |
| 172 | + * |
| 173 | + * @return array of extended key usage ID name or oid |
| 174 | + */ |
| 175 | + getExtExtKeyUsageName(): string[] |
| 176 | + |
| 177 | + /** |
| 178 | + * Get subjectAltName value as array of string in the certificate. |
| 179 | + * |
| 180 | + * @deprecated |
| 181 | + * |
| 182 | + * @return array of alt names |
| 183 | + */ |
| 184 | + getExtSubjectAltName(): string[] |
| 185 | + |
| 186 | + /** |
| 187 | + * Get subjectAltName value as array of string in the certificate. |
| 188 | + * |
| 189 | + * @return array of alt name array |
| 190 | + */ |
| 191 | + getExtSubjectAltName2(): Array<[string, string]> |
| 192 | + |
| 193 | + /** |
| 194 | + * Get array of string for fullName URIs in cRLDistributionPoints(CDP) in the certificate. |
| 195 | + * |
| 196 | + * @return array of fullName URIs of CDP of the certificate |
| 197 | + */ |
| 198 | + getExtCRLDistributionPointsURI(): string[] |
| 199 | + |
| 200 | + /** |
| 201 | + * Get AuthorityInfoAccess extension value in the certificate as associative array. |
| 202 | + * |
| 203 | + * @return associative array of AIA extension properties |
| 204 | + */ |
| 205 | + getExtAIAInfo(): { ocsp: string[], caissuer: string[] } |
| 206 | + |
| 207 | + /** |
| 208 | + * Get CertificatePolicies extension value in the certificate as array. |
| 209 | + * |
| 210 | + * @return array of PolicyInformation JSON object |
| 211 | + */ |
| 212 | + getExtCertificatePolicies(): Array<{ id: number, cps: string, unotice: string }> |
| 213 | + |
| 214 | + /** |
| 215 | + * Read PEM formatted X.509 certificate from string. |
| 216 | + * |
| 217 | + * @param sCertPEM string for PEM formatted X.509 certificate |
| 218 | + */ |
| 219 | + readCertPEM(sCertPEM: string): void |
| 220 | + |
| 221 | + /** |
| 222 | + * Read a hexadecimal string of X.509 certificate |
| 223 | + * |
| 224 | + * @param sCertHex hexadecimal string of X.509 certificate |
| 225 | + */ |
| 226 | + readCertHex(sCertHex: string): void |
| 227 | + |
| 228 | + /** |
| 229 | + * Get certificate information as string. |
| 230 | + * |
| 231 | + * @return certificate information string |
| 232 | + */ |
| 233 | + getInfo(): string |
| 234 | + |
| 235 | + /** |
| 236 | + * Get distinguished name string in OpenSSL online format from hexadecimal string of ASN.1 DER X.500 name. |
| 237 | + * |
| 238 | + * @param hex hexadecimal string of ASN.1 DER distinguished name |
| 239 | + * @param idx index of hexadecimal string (DEFAULT=0) |
| 240 | + * |
| 241 | + * @return OpenSSL online format distinguished name. |
| 242 | + */ |
| 243 | + static hex2dn(hex: string, idx?: number): string[] |
| 244 | + |
| 245 | + /** |
| 246 | + * Get relative distinguished name string in OpenSSL online format from hexadecimal string of ASN.1 DER RDN. |
| 247 | + * |
| 248 | + * @param hex hexadecimal string of ASN.1 DER concludes relative distinguished name |
| 249 | + * @param idx index of hexadecimal string (DEFAULT=0) |
| 250 | + * |
| 251 | + * @return OpenSSL online format relative distinguished name |
| 252 | + */ |
| 253 | + static hex2rdn(hex: string, idx?: number): string |
| 254 | + |
| 255 | + /** |
| 256 | + * Get string from hexadecimal string of ASN.1 DER AttributeTypeAndValue |
| 257 | + * |
| 258 | + * @param hex hexadecimal string of ASN.1 DER concludes AttributeTypeAndValue |
| 259 | + * @param idx index of hexadecimal string (DEFAULT=0) |
| 260 | + * |
| 261 | + * @return string representation of AttributeTypeAndValue (ex. C=US) |
| 262 | + */ |
| 263 | + static hex2attrTypeValue(hex: string, idx?: number): string |
| 264 | + |
| 265 | + /** |
| 266 | + * Get RSA/DSA/ECDSA public key object from X.509 certificate hexadecimal string. |
| 267 | + * |
| 268 | + * @param h hexadecimal string of X.509 certificate for RSA/ECDSA/DSA public key |
| 269 | + * |
| 270 | + * @return returns RSAKey/KJUR.crypto.{ECDSA,DSA} object of public key |
| 271 | + */ |
| 272 | + static getPublicKeyFromCertHex(h: string) |
| 273 | + |
| 274 | + /** |
| 275 | + * Get RSA/DSA/ECDSA public key object from PEM certificate string. |
| 276 | + * |
| 277 | + * @param sCertPEM PEM formatted RSA/ECDSA/DSA X.509 certificate |
| 278 | + * |
| 279 | + * @return returns RSAKey/KJUR.crypto.{ECDSA,DSA} object of public key |
| 280 | + */ |
| 281 | + static getPublicKeyFromCertPEM(sCertPEM: string) |
| 282 | + |
| 283 | + /** |
| 284 | + * Get public key information from PEM certificate. |
| 285 | + * |
| 286 | + * @param sCertPEM string of PEM formatted certificate |
| 287 | + * |
| 288 | + * @return hash of information for public key |
| 289 | + */ |
| 290 | + static getPublicKeyInfoPropOfCertPEM(sCertPEM: string) |
| 291 | + } |
| 292 | + |
| 293 | + function hextob64(s: string): string |
| 294 | + |
| 295 | + function pemtohex(s: string, sHead?: string): string |
| 296 | +} |
0 commit comments