mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add forge.pki.getPublicKeyFingerprint to node-forge (#41470)
This commit is contained in:
parent
82f4b0fcff
commit
ff2cdfa741
33
types/node-forge/index.d.ts
vendored
33
types/node-forge/index.d.ts
vendored
@ -66,6 +66,35 @@ declare module "node-forge" {
|
||||
legacy?: boolean;
|
||||
};
|
||||
|
||||
interface ByteBufferFingerprintOptions {
|
||||
/**
|
||||
* @description The type of fingerprint. If not specified, defaults to 'RSAPublicKey'
|
||||
*/
|
||||
type?: 'SubjectPublicKeyInfo' | 'RSAPublicKey';
|
||||
/**
|
||||
* @description the delimiter to use between bytes for `hex` encoded output
|
||||
*/
|
||||
delimiter?: string;
|
||||
/**
|
||||
* @description if not specified defaults to `md.md5`
|
||||
*/
|
||||
md?: md.MessageDigest;
|
||||
}
|
||||
|
||||
interface HexFingerprintOptions extends ByteBufferFingerprintOptions {
|
||||
/**
|
||||
* @description if not specified, the function will return `ByteStringBuffer`
|
||||
*/
|
||||
encoding: 'hex';
|
||||
}
|
||||
|
||||
interface BinaryFingerprintOptions extends ByteBufferFingerprintOptions {
|
||||
/**
|
||||
* @description if not specified, the function will return `ByteStringBuffer`
|
||||
*/
|
||||
encoding: 'binary';
|
||||
}
|
||||
|
||||
interface KeyPair {
|
||||
publicKey: PublicKey;
|
||||
privateKey: PrivateKey;
|
||||
@ -374,6 +403,10 @@ declare module "node-forge" {
|
||||
type setRsaPublicKey = typeof rsa.setPublicKey;
|
||||
|
||||
function wrapRsaPrivateKey(privateKey: asn1.Asn1): asn1.Asn1;
|
||||
|
||||
function getPublicKeyFingerprint(publicKey: PublicKey, options?: ByteBufferFingerprintOptions): util.ByteStringBuffer;
|
||||
function getPublicKeyFingerprint(publicKey: PublicKey, options: HexFingerprintOptions): Hex;
|
||||
function getPublicKeyFingerprint(publicKey: PublicKey, options: BinaryFingerprintOptions): Bytes;
|
||||
}
|
||||
|
||||
namespace random {
|
||||
|
||||
@ -384,3 +384,22 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin
|
||||
privateKey
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let byteBuffer: forge.util.ByteBuffer = forge.pki.getPublicKeyFingerprint(cert.publicKey, {
|
||||
type: 'SubjectPublicKeyInfo',
|
||||
md: forge.md.sha256.create(),
|
||||
});
|
||||
|
||||
let hex: forge.Hex = forge.pki.getPublicKeyFingerprint(cert.publicKey, {
|
||||
type: 'SubjectPublicKeyInfo',
|
||||
md: forge.md.sha256.create(),
|
||||
encoding: 'hex'
|
||||
});
|
||||
|
||||
let bytes: forge.Bytes = forge.pki.getPublicKeyFingerprint(cert.publicKey, {
|
||||
type: 'SubjectPublicKeyInfo',
|
||||
md: forge.md.sha256.create(),
|
||||
encoding: 'binary'
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user