feat(crypto): 新增 validatePgpPrivateKey 校验函数
This commit is contained in:
@@ -2,5 +2,5 @@ export { aesGcmDecrypt, aesGcmEncrypt } from './aes-gcm'
|
|||||||
export { sha256, sha256Hex } from './hash'
|
export { sha256, sha256Hex } from './hash'
|
||||||
export { hkdfSha256 } from './hkdf'
|
export { hkdfSha256 } from './hkdf'
|
||||||
export { hmacSha256, hmacSha256Base64 } from './hmac'
|
export { hmacSha256, hmacSha256Base64 } from './hmac'
|
||||||
export { generatePgpKeyPair, pgpSignDetached, pgpVerifyDetached } from './pgp'
|
export { generatePgpKeyPair, pgpSignDetached, pgpVerifyDetached, validatePgpPrivateKey } from './pgp'
|
||||||
export { rsaOaepEncrypt } from './rsa-oaep'
|
export { rsaOaepEncrypt } from './rsa-oaep'
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ export const generatePgpKeyPair = async (
|
|||||||
* @param armoredPrivateKey - ASCII-armored private key
|
* @param armoredPrivateKey - ASCII-armored private key
|
||||||
* @returns ASCII-armored detached signature (signature.asc content)
|
* @returns ASCII-armored detached signature (signature.asc content)
|
||||||
*/
|
*/
|
||||||
|
export const validatePgpPrivateKey = async (armoredKey: string): Promise<void> => {
|
||||||
|
await openpgp.readPrivateKey({ armoredKey })
|
||||||
|
}
|
||||||
|
|
||||||
export const pgpSignDetached = async (data: Uint8Array, armoredPrivateKey: string): Promise<string> => {
|
export const pgpSignDetached = async (data: Uint8Array, armoredPrivateKey: string): Promise<string> => {
|
||||||
const privateKey = await openpgp.readPrivateKey({ armoredKey: armoredPrivateKey })
|
const privateKey = await openpgp.readPrivateKey({ armoredKey: armoredPrivateKey })
|
||||||
const message = await openpgp.createMessage({ binary: data })
|
const message = await openpgp.createMessage({ binary: data })
|
||||||
|
|||||||
Reference in New Issue
Block a user