mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
암호 키 생성 페이지에서 검증키와 서명키를 함께 생성하도록 변경
This commit is contained in:
@@ -8,7 +8,7 @@ export const decodeFromBase64 = (data: string) => {
|
||||
return Uint8Array.from(atob(data), (c) => c.charCodeAt(0)).buffer;
|
||||
};
|
||||
|
||||
export const generateRSAKeyPair = async () => {
|
||||
export const generateRSAEncKeyPair = async () => {
|
||||
const keyPair = await window.crypto.subtle.generateKey(
|
||||
{
|
||||
name: "RSA-OAEP",
|
||||
@@ -22,6 +22,20 @@ export const generateRSAKeyPair = async () => {
|
||||
return keyPair;
|
||||
};
|
||||
|
||||
export const generateRSASigKeyPair = async () => {
|
||||
const keyPair = await window.crypto.subtle.generateKey(
|
||||
{
|
||||
name: "RSA-PSS",
|
||||
modulusLength: 4096,
|
||||
publicExponent: new Uint8Array([1, 0, 1]),
|
||||
hash: "SHA-256",
|
||||
} satisfies RsaHashedKeyGenParams,
|
||||
true,
|
||||
["sign", "verify"],
|
||||
);
|
||||
return keyPair;
|
||||
};
|
||||
|
||||
export const makeRSAKeyNonextractable = async (key: CryptoKey, type: RSAKeyType) => {
|
||||
const { format, key: exportedKey } = await exportRSAKey(key, type);
|
||||
return await window.crypto.subtle.importKey(
|
||||
@@ -64,6 +78,17 @@ export const decryptRSACiphertext = async (ciphertext: ArrayBuffer, privateKey:
|
||||
);
|
||||
};
|
||||
|
||||
export const signRSAMessage = async (message: ArrayBuffer, privateKey: CryptoKey) => {
|
||||
return await window.crypto.subtle.sign(
|
||||
{
|
||||
name: "RSA-PSS",
|
||||
saltLength: 32,
|
||||
} satisfies RsaPssParams,
|
||||
privateKey,
|
||||
message,
|
||||
);
|
||||
};
|
||||
|
||||
export const generateAESKey = async () => {
|
||||
return await window.crypto.subtle.generateKey(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user