feat(fips): requested changes (function renaming)

This commit is contained in:
Daniel Hougaard
2025-07-14 21:48:13 +04:00
parent dad5153f61
commit 260ef05644
39 changed files with 718 additions and 531 deletions
@@ -336,7 +336,10 @@ export const authLoginServiceFactory = ({
const hashedPassword = await crypto.hashing().createHash(password, cfg.SALT_ROUNDS);
const { iv, tag, ciphertext, encoding } = crypto.encryption().encryptWithRootEncryptionKey(privateKey);
const { iv, tag, ciphertext, encoding } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(privateKey);
await userDAL.updateUserEncryptionByUserId(userEnc.userId, {
serverPrivateKey: null,
@@ -222,12 +222,15 @@ export const authPaswordServiceFactory = ({
user.serverEncryptedPrivateKeyEncoding &&
user.encryptionVersion === UserEncryption.V2
) {
privateKey = crypto.encryption().decryptWithRootEncryptionKey({
iv: user.serverEncryptedPrivateKeyIV,
tag: user.serverEncryptedPrivateKeyTag,
ciphertext: user.serverEncryptedPrivateKey,
keyEncoding: user.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
privateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
iv: user.serverEncryptedPrivateKeyIV,
tag: user.serverEncryptedPrivateKeyTag,
ciphertext: user.serverEncryptedPrivateKey,
keyEncoding: user.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
} else {
throw new BadRequestError({
message: "Cannot reset password without current credentials or recovery method",
@@ -240,7 +243,7 @@ export const authPaswordServiceFactory = ({
privateKey
});
const { tag, iv, ciphertext, encoding } = crypto.encryption().encryptWithRootEncryptionKey(privateKey);
const { tag, iv, ciphertext, encoding } = crypto.encryption().symmetric().encryptWithRootEncryptionKey(privateKey);
await userDAL.updateUserEncryptionByUserId(userId, {
hashedPassword: newHashedPassword,
@@ -201,7 +201,7 @@ export const authSignupServiceFactory = ({
tag: encryptedPrivateKeyTag,
encryptionVersion: UserEncryption.V2
});
const { tag, encoding, ciphertext, iv } = crypto.encryption().encryptWithRootEncryptionKey(privateKey);
const { tag, encoding, ciphertext, iv } = crypto.encryption().symmetric().encryptWithRootEncryptionKey(privateKey);
const updateduser = await authDAL.transaction(async (tx) => {
const us = await userDAL.updateById(user.id, { firstName, lastName, isAccepted: true }, tx);
if (!us) throw new Error("User not found");
@@ -222,12 +222,15 @@ export const authSignupServiceFactory = ({
systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyEncoding
) {
// get server generated password
const serverGeneratedPassword = crypto.encryption().decryptWithRootEncryptionKey({
iv: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyIV,
tag: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyTag,
ciphertext: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKey,
keyEncoding: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
const serverGeneratedPassword = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
iv: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyIV,
tag: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyTag,
ciphertext: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKey,
keyEncoding: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
const serverGeneratedPrivateKey = await getUserPrivateKey(serverGeneratedPassword, {
...systemGeneratedUserEncryptionKey
});
@@ -444,7 +447,7 @@ export const authSignupServiceFactory = ({
tag: encryptedPrivateKeyTag,
encryptionVersion: 2
});
const { tag, encoding, ciphertext, iv } = crypto.encryption().encryptWithRootEncryptionKey(privateKey);
const { tag, encoding, ciphertext, iv } = crypto.encryption().symmetric().encryptWithRootEncryptionKey(privateKey);
const updateduser = await authDAL.transaction(async (tx) => {
const us = await userDAL.updateById(user.id, { firstName, lastName, isAccepted: true }, tx);
if (!us) throw new Error("User not found");
@@ -461,12 +464,15 @@ export const authSignupServiceFactory = ({
systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyEncoding
) {
// get server generated password
const serverGeneratedPassword = crypto.encryption().decryptWithRootEncryptionKey({
iv: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyIV,
tag: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyTag,
ciphertext: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKey,
keyEncoding: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
const serverGeneratedPassword = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
iv: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyIV,
tag: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyTag,
ciphertext: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKey,
keyEncoding: systemGeneratedUserEncryptionKey.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
const serverGeneratedPrivateKey = await getUserPrivateKey(serverGeneratedPassword, {
...systemGeneratedUserEncryptionKey
});
@@ -98,7 +98,7 @@ export const externalMigrationQueueFactory = ({
template: SmtpTemplates.ExternalImportStarted
});
const decrypted = crypto.encryption().decryptWithRootEncryptionKey({
const decrypted = crypto.encryption().symmetric().decryptWithRootEncryptionKey({
ciphertext: data.ciphertext,
iv: data.iv,
keyEncoding: data.encoding,
@@ -56,7 +56,7 @@ export const externalMigrationServiceFactory = ({
actorAuthMethod
});
const encrypted = crypto.encryption().encryptWithRootEncryptionKey(stringifiedJson);
const encrypted = crypto.encryption().symmetric().encryptWithRootEncryptionKey(stringifiedJson);
await externalMigrationQueue.startImport({
actorEmail: user.email!,
@@ -212,12 +212,15 @@ export const groupProjectServiceFactory = ({
});
}
const botPrivateKey = crypto.encryption().decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
const botPrivateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
const plaintextProjectKey = crypto.encryption().asymmetric().decrypt({
ciphertext: ghostUserLatestKey.encryptedKey,
@@ -218,7 +218,7 @@ export const integrationAuthServiceFactory = ({
} else {
if (!botKey) throw new NotFoundError({ message: `Project bot key for project with ID '${projectId}' not found` });
if (tokenExchange.refreshToken) {
const refreshEncToken = crypto.encryption().encryptSymmetric({
const refreshEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenExchange.refreshToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -229,7 +229,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.refreshCiphertext = refreshEncToken.ciphertext;
}
if (tokenExchange.accessToken) {
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenExchange.accessToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -355,7 +355,7 @@ export const integrationAuthServiceFactory = ({
url,
updateDoc.metadata as Record<string, string>
);
const refreshEncToken = crypto.encryption().encryptSymmetric({
const refreshEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenDetails.refreshToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -363,7 +363,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.refreshIV = refreshEncToken.iv;
updateDoc.refreshTag = refreshEncToken.tag;
updateDoc.refreshCiphertext = refreshEncToken.ciphertext;
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenDetails.accessToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -377,7 +377,7 @@ export const integrationAuthServiceFactory = ({
if (!refreshToken && (accessId || accessToken || awsAssumeIamRoleArn)) {
if (accessToken) {
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: accessToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -387,7 +387,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.accessCiphertext = accessEncToken.ciphertext;
}
if (accessId) {
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: accessId,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -397,7 +397,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.accessIdCiphertext = accessEncToken.ciphertext;
}
if (awsAssumeIamRoleArn) {
const awsAssumeIamRoleArnEnc = crypto.encryption().encryptSymmetric({
const awsAssumeIamRoleArnEnc = crypto.encryption().symmetric().encrypt({
plaintext: awsAssumeIamRoleArn,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -516,7 +516,7 @@ export const integrationAuthServiceFactory = ({
url,
updateDoc.metadata as Record<string, string>
);
const refreshEncToken = crypto.encryption().encryptSymmetric({
const refreshEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenDetails.refreshToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -525,7 +525,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.refreshTag = refreshEncToken.tag;
updateDoc.refreshCiphertext = refreshEncToken.ciphertext;
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenDetails.accessToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -540,7 +540,7 @@ export const integrationAuthServiceFactory = ({
if (!refreshToken && (accessId || accessToken || awsAssumeIamRoleArn)) {
if (accessToken) {
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: accessToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -550,7 +550,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.accessCiphertext = accessEncToken.ciphertext;
}
if (accessId) {
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: accessId,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -560,7 +560,7 @@ export const integrationAuthServiceFactory = ({
updateDoc.accessIdCiphertext = accessEncToken.ciphertext;
}
if (awsAssumeIamRoleArn) {
const awsAssumeIamRoleArnEnc = crypto.encryption().encryptSymmetric({
const awsAssumeIamRoleArnEnc = crypto.encryption().symmetric().encrypt({
plaintext: awsAssumeIamRoleArn,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -648,7 +648,7 @@ export const integrationAuthServiceFactory = ({
} else {
if (!botKey) throw new NotFoundError({ message: "Project bot key not found" });
if (integrationAuth.accessTag && integrationAuth.accessIV && integrationAuth.accessCiphertext) {
accessToken = crypto.encryption().decryptSymmetric({
accessToken = crypto.encryption().symmetric().decrypt({
ciphertext: integrationAuth.accessCiphertext,
iv: integrationAuth.accessIV,
tag: integrationAuth.accessTag,
@@ -658,7 +658,7 @@ export const integrationAuthServiceFactory = ({
}
if (integrationAuth.refreshCiphertext && integrationAuth.refreshIV && integrationAuth.refreshTag) {
const refreshToken = crypto.encryption().decryptSymmetric({
const refreshToken = crypto.encryption().symmetric().decrypt({
key: botKey,
ciphertext: integrationAuth.refreshCiphertext,
iv: integrationAuth.refreshIV,
@@ -675,13 +675,13 @@ export const integrationAuthServiceFactory = ({
integrationAuth.metadata as Record<string, string>
);
const refreshEncToken = crypto.encryption().encryptSymmetric({
const refreshEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenDetails.refreshToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const accessEncToken = crypto.encryption().encryptSymmetric({
const accessEncToken = crypto.encryption().symmetric().encrypt({
plaintext: tokenDetails.accessToken,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -701,7 +701,7 @@ export const integrationAuthServiceFactory = ({
if (!accessToken) throw new BadRequestError({ message: "Missing access token" });
if (integrationAuth.accessIdTag && integrationAuth.accessIdIV && integrationAuth.accessIdCiphertext) {
accessId = crypto.encryption().decryptSymmetric({
accessId = crypto.encryption().symmetric().decrypt({
key: botKey,
ciphertext: integrationAuth.accessIdCiphertext,
iv: integrationAuth.accessIdIV,
@@ -111,7 +111,7 @@ const getIntegrationSecretsV1 = async (
const secrets = await secretDAL.findByFolderId(dto.folderId);
secrets.forEach((secret) => {
const secretKey = crypto.encryption().decryptSymmetric({
const secretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
@@ -144,12 +144,15 @@ export const orgAdminServiceFactory = ({
});
}
const botPrivateKey = crypto.encryption().decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
const botPrivateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
const userEncryptionKey = await userDAL.findUserEncKeyByUserId(actorId);
if (!userEncryptionKey)
+13 -8
View File
@@ -508,14 +508,14 @@ export const orgServiceFactory = ({
tag: privateKeyTag,
encoding: privateKeyKeyEncoding,
algorithm: privateKeyAlgorithm
} = crypto.encryption().encryptWithRootEncryptionKey(privateKey);
} = crypto.encryption().symmetric().encryptWithRootEncryptionKey(privateKey);
const {
ciphertext: encryptedSymmetricKey,
iv: symmetricKeyIV,
tag: symmetricKeyTag,
encoding: symmetricKeyKeyEncoding,
algorithm: symmetricKeyAlgorithm
} = crypto.encryption().encryptWithRootEncryptionKey(key);
} = crypto.encryption().symmetric().encryptWithRootEncryptionKey(key);
const customerId = await licenseService.generateOrgCustomerId(orgName, userEmail);
const organization = await orgDAL.transaction(async (tx) => {
@@ -879,6 +879,7 @@ export const orgServiceFactory = ({
const serverGeneratedPassword = crypto.randomBytes(32).toString("hex");
const { tag, encoding, ciphertext, iv } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(serverGeneratedPassword);
const encKeys = await generateUserSrpKeys(inviteeEmail, serverGeneratedPassword);
await userDAL.createUserEncryption(
@@ -1099,6 +1100,7 @@ export const orgServiceFactory = ({
const { iv, tag, ciphertext, encoding, algorithm } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(newGhostUser.keys.plainPrivateKey);
if (autoGeneratedBot) {
await projectBotDAL.updateById(
@@ -1137,12 +1139,15 @@ export const orgServiceFactory = ({
});
}
const botPrivateKey = crypto.encryption().decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
const botPrivateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
const newWsMembers = assignWorkspaceKeysToMembers({
decryptKey: ghostUserLatestKey,
@@ -7,12 +7,15 @@ import { TProjectDALFactory } from "../project/project-dal";
import { TGetPrivateKeyDTO } from "./project-bot-types";
export const getBotPrivateKey = ({ bot }: TGetPrivateKeyDTO) => {
return crypto.encryption().decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
return crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
keyEncoding: bot.keyEncoding as SecretKeyEncoding,
iv: bot.iv,
tag: bot.tag,
ciphertext: bot.encryptedPrivateKey
});
};
export const getBotKeyFnFactory = (
@@ -46,12 +49,15 @@ export const getBotKeyFnFactory = (
projectV1Keys.serverEncryptedPrivateKeyTag &&
projectV1Keys.serverEncryptedPrivateKeyEncoding
) {
userPrivateKey = crypto.encryption().decryptWithRootEncryptionKey({
iv: projectV1Keys.serverEncryptedPrivateKeyIV,
tag: projectV1Keys.serverEncryptedPrivateKeyTag,
ciphertext: projectV1Keys.serverEncryptedPrivateKey,
keyEncoding: projectV1Keys.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
userPrivateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
iv: projectV1Keys.serverEncryptedPrivateKeyIV,
tag: projectV1Keys.serverEncryptedPrivateKeyTag,
ciphertext: projectV1Keys.serverEncryptedPrivateKey,
keyEncoding: projectV1Keys.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
}
const workspaceKey = crypto.encryption().asymmetric().decrypt({
ciphertext: projectV1Keys.projectEncryptedKey,
@@ -62,6 +68,7 @@ export const getBotKeyFnFactory = (
const botKey = await crypto.encryption().asymmetric().generateKeyPair();
const { iv, tag, ciphertext, encoding, algorithm } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(botKey.privateKey);
const encryptedWorkspaceKey = crypto
.encryption()
@@ -58,6 +58,7 @@ export const projectBotServiceFactory = ({
const { iv, tag, ciphertext, encoding, algorithm } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(keys.privateKey);
const project = await projectDAL.findById(projectId, tx);
+65 -43
View File
@@ -114,7 +114,7 @@ export const projectQueueFactory = ({
await projectDAL.setProjectUpgradeStatus(data.projectId, ProjectUpgradeStatus.InProgress); // Set the status to in progress. This is important to prevent multiple upgrades at the same time.
const userPrivateKey = crypto.encryption().decryptWithRootEncryptionKey({
const userPrivateKey = crypto.encryption().symmetric().decryptWithRootEncryptionKey({
keyEncoding: data.encryptedPrivateKey.keyEncoding,
ciphertext: data.encryptedPrivateKey.encryptedKey,
iv: data.encryptedPrivateKey.encryptedKeyIv,
@@ -316,6 +316,7 @@ export const projectQueueFactory = ({
// Encrypt the bot private key (which is the same as the ghost user)
const { iv, tag, ciphertext, encoding, algorithm } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(ghostUser.keys.plainPrivateKey);
// 5. Create a bot for the project
@@ -337,12 +338,15 @@ export const projectQueueFactory = ({
tx
);
const botPrivateKey = crypto.encryption().decryptWithRootEncryptionKey({
keyEncoding: newBot.keyEncoding as SecretKeyEncoding,
iv: newBot.iv,
tag: newBot.tag,
ciphertext: newBot.encryptedPrivateKey
});
const botPrivateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
keyEncoding: newBot.keyEncoding as SecretKeyEncoding,
iv: newBot.iv,
tag: newBot.tag,
ciphertext: newBot.encryptedPrivateKey
});
const botKey = crypto.encryption().asymmetric().decrypt({
ciphertext: newBot.encryptedProjectKey!,
@@ -356,23 +360,29 @@ export const projectQueueFactory = ({
const updatedSecretApprovals: TSecretApprovalRequestsSecrets[] = [];
const updatedIntegrationAuths: TIntegrationAuths[] = [];
for (const rawSecret of decryptedSecrets) {
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: rawSecret.decrypted.secretKey,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: rawSecret.decrypted.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: rawSecret.decrypted.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: rawSecret.decrypted.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: rawSecret.decrypted.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const payload: TSecrets = {
...rawSecret.original,
@@ -399,23 +409,29 @@ export const projectQueueFactory = ({
}
for (const rawSecretVersion of decryptedSecretVersions) {
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: rawSecretVersion.decrypted.secretKey,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: rawSecretVersion.decrypted.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: rawSecretVersion.decrypted.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: rawSecretVersion.decrypted.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: rawSecretVersion.decrypted.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const payload: TSecretVersions = {
...rawSecretVersion.original,
@@ -442,21 +458,27 @@ export const projectQueueFactory = ({
}
for (const rawSecretApproval of decryptedApprovalSecrets) {
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: rawSecretApproval.decrypted.secretKey,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: rawSecretApproval.decrypted.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: rawSecretApproval.decrypted.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: rawSecretApproval.decrypted.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: rawSecretApproval.decrypted.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const payload: TSecretApprovalRequestsSecrets = {
...rawSecretApproval.original,
@@ -483,17 +505,17 @@ export const projectQueueFactory = ({
}
for (const integrationAuth of decryptedIntegrationAuths) {
const access = crypto.encryption().encryptSymmetric({
const access = crypto.encryption().symmetric().encrypt({
plaintext: integrationAuth.decrypted.access,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const accessId = crypto.encryption().encryptSymmetric({
const accessId = crypto.encryption().symmetric().encrypt({
plaintext: integrationAuth.decrypted.accessId,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const refresh = crypto.encryption().encryptSymmetric({
const refresh = crypto.encryption().symmetric().encrypt({
plaintext: integrationAuth.decrypted.refresh,
key: botKey,
keySize: SymmetricKeySize.Bits128
@@ -379,6 +379,7 @@ export const projectServiceFactory = ({
const { iv, tag, ciphertext, encoding, algorithm } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(ghostUser.keys.plainPrivateKey);
// 5. Create & a bot for the project
@@ -822,7 +823,7 @@ export const projectServiceFactory = ({
});
}
const encryptedPrivateKey = crypto.encryption().encryptWithRootEncryptionKey(userPrivateKey);
const encryptedPrivateKey = crypto.encryption().symmetric().encryptWithRootEncryptionKey(userPrivateKey);
await projectQueue.upgradeProject({
projectId,
+42 -30
View File
@@ -234,14 +234,14 @@ export const interpolateSecrets = ({ projectId, secretEncKey, secretDAL, folderD
const secrets = await secretDAL.findByFolderId(folder.id);
const decryptedSec = secrets.reduce<Record<string, string>>((prev, secret) => {
const decryptedSecretKey = crypto.encryption().decryptSymmetric({
const decryptedSecretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
key: secretEncKey,
keySize: SymmetricKeySize.Bits128
});
const decryptedSecretValue = crypto.encryption().decryptSymmetric({
const decryptedSecretValue = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretValueCiphertext,
iv: secret.secretValueIV,
tag: secret.secretValueTag,
@@ -363,7 +363,7 @@ export const decryptSecretRaw = (
},
key: string
) => {
const secretKey = crypto.encryption().decryptSymmetric({
const secretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
@@ -372,7 +372,7 @@ export const decryptSecretRaw = (
});
const secretValue = !secret.secretValueHidden
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretValueCiphertext,
iv: secret.secretValueIV,
tag: secret.secretValueTag,
@@ -384,7 +384,7 @@ export const decryptSecretRaw = (
let secretComment = "";
if (secret.secretCommentCiphertext && secret.secretCommentIV && secret.secretCommentTag) {
secretComment = crypto.encryption().decryptSymmetric({
secretComment = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretCommentCiphertext,
iv: secret.secretCommentIV,
tag: secret.secretCommentTag,
@@ -879,22 +879,28 @@ export const createManySecretsRawFnFactory = ({
});
const inputSecrets = secrets.map((secret) => {
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: secret.secretName,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secret.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secret.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretReferences = getAllNestedSecretReferences(secret.secretValue || "");
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secret.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secret.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
return {
type: secret.type,
@@ -1078,22 +1084,28 @@ export const updateManySecretsRawFnFactory = ({
throw new BadRequestError({ message: "New secret name cannot be empty" });
}
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: secret.secretName,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secret.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secret.secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretReferences = getAllNestedSecretReferences(secret.secretValue || "");
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secret.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secret.secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
return {
type: secret.type,
@@ -1176,7 +1188,7 @@ export const decryptSecretWithBot = (
>,
key: string
) => {
const secretKey = crypto.encryption().decryptSymmetric({
const secretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
@@ -1184,7 +1196,7 @@ export const decryptSecretWithBot = (
keySize: SymmetricKeySize.Bits128
});
const secretValue = crypto.encryption().decryptSymmetric({
const secretValue = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretValueCiphertext,
iv: secret.secretValueIV,
tag: secret.secretValueTag,
@@ -1195,7 +1207,7 @@ export const decryptSecretWithBot = (
let secretComment = "";
if (secret.secretCommentCiphertext && secret.secretCommentIV && secret.secretCommentTag) {
secretComment = crypto.encryption().decryptSymmetric({
secretComment = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretCommentCiphertext,
iv: secret.secretCommentIV,
tag: secret.secretCommentTag,
+27 -23
View File
@@ -503,7 +503,7 @@ export const secretQueueFactory = ({
const secrets = await secretDAL.findByFolderId(dto.folderId);
await Promise.allSettled(
secrets.map(async (secret) => {
const secretKey = crypto.encryption().decryptSymmetric({
const secretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
@@ -511,7 +511,7 @@ export const secretQueueFactory = ({
keySize: SymmetricKeySize.Bits128
});
const secretValue = crypto.encryption().decryptSymmetric({
const secretValue = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretValueCiphertext,
iv: secret.secretValueIV,
tag: secret.secretValueTag,
@@ -528,7 +528,7 @@ export const secretQueueFactory = ({
content[secretKey] = { value: expandedSecretValue || "" };
if (secret.secretCommentCiphertext && secret.secretCommentIV && secret.secretCommentTag) {
const commentValue = crypto.encryption().decryptSymmetric({
const commentValue = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretCommentCiphertext,
iv: secret.secretCommentIV,
tag: secret.secretCommentTag,
@@ -954,13 +954,16 @@ export const secretQueueFactory = ({
integrationAuth.awsAssumeIamRoleArnIV &&
integrationAuth.awsAssumeIamRoleArnCipherText
) {
awsAssumeRoleArn = crypto.encryption().decryptSymmetric({
ciphertext: integrationAuth.awsAssumeIamRoleArnCipherText,
iv: integrationAuth.awsAssumeIamRoleArnIV,
tag: integrationAuth.awsAssumeIamRoleArnTag,
key: botKey as string,
keySize: SymmetricKeySize.Bits128
});
awsAssumeRoleArn = crypto
.encryption()
.symmetric()
.decrypt({
ciphertext: integrationAuth.awsAssumeIamRoleArnCipherText,
iv: integrationAuth.awsAssumeIamRoleArnIV,
tag: integrationAuth.awsAssumeIamRoleArnTag,
key: botKey as string,
keySize: SymmetricKeySize.Bits128
});
}
const suffixedSecrets: typeof secrets = {};
@@ -1241,6 +1244,7 @@ export const secretQueueFactory = ({
);
const { iv, tag, ciphertext, encoding, algorithm } = crypto
.encryption()
.symmetric()
.encryptWithRootEncryptionKey(ghostUser.keys.plainPrivateKey);
await projectBotDAL.updateById(
bot.id,
@@ -1275,14 +1279,14 @@ export const secretQueueFactory = ({
await secretV2BridgeDAL.batchInsert(
projectV1Secrets.map((el) => {
const key = crypto.encryption().decryptSymmetric({
const key = crypto.encryption().symmetric().decrypt({
ciphertext: el.secretKeyCiphertext,
iv: el.secretKeyIV,
tag: el.secretKeyTag,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const value = crypto.encryption().decryptSymmetric({
const value = crypto.encryption().symmetric().decrypt({
ciphertext: el.secretValueCiphertext,
iv: el.secretValueIV,
tag: el.secretValueTag,
@@ -1291,7 +1295,7 @@ export const secretQueueFactory = ({
});
const comment =
el.secretCommentCiphertext && el.secretCommentTag && el.secretCommentIV
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.secretCommentCiphertext,
iv: el.secretCommentIV,
tag: el.secretCommentTag,
@@ -1346,14 +1350,14 @@ export const secretQueueFactory = ({
});
if (projectV3SecretVersionsGroupById[el.id]) return;
const key = crypto.encryption().decryptSymmetric({
const key = crypto.encryption().symmetric().decrypt({
ciphertext: el.secretKeyCiphertext,
iv: el.secretKeyIV,
tag: el.secretKeyTag,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const value = crypto.encryption().decryptSymmetric({
const value = crypto.encryption().symmetric().decrypt({
ciphertext: el.secretValueCiphertext,
iv: el.secretValueIV,
tag: el.secretValueTag,
@@ -1362,7 +1366,7 @@ export const secretQueueFactory = ({
});
const comment =
el.secretCommentCiphertext && el.secretCommentTag && el.secretCommentIV
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.secretCommentCiphertext,
iv: el.secretCommentIV,
tag: el.secretCommentTag,
@@ -1408,14 +1412,14 @@ export const secretQueueFactory = ({
);
Object.values(latestSecretVersionByFolder).forEach((el) => {
if (projectV3SecretVersionsGroupById[el.id]) return;
const key = crypto.encryption().decryptSymmetric({
const key = crypto.encryption().symmetric().decrypt({
ciphertext: el.secretKeyCiphertext,
iv: el.secretKeyIV,
tag: el.secretKeyTag,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const value = crypto.encryption().decryptSymmetric({
const value = crypto.encryption().symmetric().decrypt({
ciphertext: el.secretValueCiphertext,
iv: el.secretValueIV,
tag: el.secretValueTag,
@@ -1424,7 +1428,7 @@ export const secretQueueFactory = ({
});
const comment =
el.secretCommentCiphertext && el.secretCommentTag && el.secretCommentIV
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.secretCommentCiphertext,
iv: el.secretCommentIV,
tag: el.secretCommentTag,
@@ -1496,7 +1500,7 @@ export const secretQueueFactory = ({
projectV1IntegrationAuths.map((el) => {
const accessToken =
el.accessIV && el.accessTag && el.accessCiphertext
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.accessCiphertext,
iv: el.accessIV,
tag: el.accessTag,
@@ -1506,7 +1510,7 @@ export const secretQueueFactory = ({
: undefined;
const accessId =
el.accessIdIV && el.accessIdTag && el.accessIdCiphertext
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.accessIdCiphertext,
iv: el.accessIdIV,
tag: el.accessIdTag,
@@ -1516,7 +1520,7 @@ export const secretQueueFactory = ({
: undefined;
const refreshToken =
el.refreshIV && el.refreshTag && el.refreshCiphertext
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.refreshCiphertext,
iv: el.refreshIV,
tag: el.refreshTag,
@@ -1526,7 +1530,7 @@ export const secretQueueFactory = ({
: undefined;
const awsAssumeRoleArn =
el.awsAssumeIamRoleArnCipherText && el.awsAssumeIamRoleArnIV && el.awsAssumeIamRoleArnTag
? crypto.encryption().decryptSymmetric({
? crypto.encryption().symmetric().decrypt({
ciphertext: el.awsAssumeIamRoleArnCipherText,
iv: el.awsAssumeIamRoleArnIV,
tag: el.awsAssumeIamRoleArnTag,
+98 -65
View File
@@ -158,13 +158,16 @@ export const secretServiceFactory = ({
return (el: { ciphertext?: string; iv: string; tag: string }) =>
projectBot?.botKey
? getAllNestedSecretReferences(
crypto.encryption().decryptSymmetric({
ciphertext: el.ciphertext || "",
iv: el.iv,
tag: el.tag,
key: projectBot.botKey,
keySize: SymmetricKeySize.Bits128
})
crypto
.encryption()
.symmetric()
.decrypt({
ciphertext: el.ciphertext || "",
iv: el.iv,
tag: el.tag,
key: projectBot.botKey,
keySize: SymmetricKeySize.Bits128
})
)
: undefined;
};
@@ -1695,21 +1698,27 @@ export const secretServiceFactory = ({
name: "bot_not_found_error"
});
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: secretName,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
if (policy) {
const approval = await secretApprovalRequestService.generateSecretApprovalRequest({
policy,
@@ -1875,22 +1884,31 @@ export const secretServiceFactory = ({
name: "bot_not_found_error"
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
plaintext: newSecretName || secretName,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretKeyEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: newSecretName || secretName,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
if (policy) {
const approval = await secretApprovalRequestService.generateSecretApprovalRequest({
@@ -2137,21 +2155,27 @@ export const secretServiceFactory = ({
const sanitizedSecrets = inputSecrets.map(
({ secretComment, secretKey, metadata, tagIds, secretValue, skipMultilineEncoding }) => {
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
const secretKeyEncrypted = crypto.encryption().symmetric().encrypt({
plaintext: secretKey,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
return {
secretName: secretKey,
skipMultilineEncoding,
@@ -2303,21 +2327,30 @@ export const secretServiceFactory = ({
secretReminderNote,
secretReminderRepeatDays
}) => {
const secretKeyEncrypted = crypto.encryption().encryptSymmetric({
plaintext: newSecretName || secretKey,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto.encryption().encryptSymmetric({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretKeyEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: newSecretName || secretKey,
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretValueEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretValue || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
const secretCommentEncrypted = crypto
.encryption()
.symmetric()
.encrypt({
plaintext: secretComment || "",
key: botKey,
keySize: SymmetricKeySize.Bits128
});
return {
secretName: secretKey,
newSecretName,
@@ -2528,7 +2561,7 @@ export const secretServiceFactory = ({
});
return secretVersions.map((el) => {
const secretKey = crypto.encryption().decryptSymmetric({
const secretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
@@ -2850,7 +2883,7 @@ export const secretServiceFactory = ({
secrets.map(({ id, secretValueCiphertext, secretValueIV, secretValueTag }) => ({
secretId: id,
references: getAllNestedSecretReferences(
crypto.encryption().decryptSymmetric({
crypto.encryption().symmetric().decrypt({
ciphertext: secretValueCiphertext,
iv: secretValueIV,
tag: secretValueTag,
@@ -2955,7 +2988,7 @@ export const secretServiceFactory = ({
const destinationActions = [ProjectPermissionSecretActions.Create, ProjectPermissionSecretActions.Edit] as const;
const decryptedSourceSecrets = sourceSecrets.map((secret) => {
const secretKey = crypto.encryption().decryptSymmetric({
const secretKey = crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
@@ -2996,7 +3029,7 @@ export const secretServiceFactory = ({
return {
...secret,
secretKey,
secretValue: crypto.encryption().decryptSymmetric({
secretValue: crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretValueCiphertext,
iv: secret.secretValueIV,
tag: secret.secretValueTag,
@@ -3022,14 +3055,14 @@ export const secretServiceFactory = ({
const decryptedDestinationSecrets = destinationSecretsFromDB.map((secret) => {
return {
...secret,
secretKey: crypto.encryption().decryptSymmetric({
secretKey: crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretKeyCiphertext,
iv: secret.secretKeyIV,
tag: secret.secretKeyTag,
key: botKey,
keySize: SymmetricKeySize.Bits128
}),
secretValue: crypto.encryption().decryptSymmetric({
secretValue: crypto.encryption().symmetric().decrypt({
ciphertext: secret.secretValueCiphertext,
iv: secret.secretValueIV,
tag: secret.secretValueTag,
@@ -501,7 +501,7 @@ export const superAdminServiceFactory = ({
const hashedPassword = await crypto.hashing().createHash(password, appCfg.SALT_ROUNDS);
const { iv, tag, ciphertext, encoding } = crypto.encryption().encryptWithRootEncryptionKey(privateKey);
const { iv, tag, ciphertext, encoding } = crypto.encryption().symmetric().encryptWithRootEncryptionKey(privateKey);
const userInfo = await userDAL.transaction(async (tx) => {
const newUser = await userDAL.create(
{
@@ -587,7 +587,7 @@ export const superAdminServiceFactory = ({
},
tx
);
const { tag, encoding, ciphertext, iv } = crypto.encryption().encryptWithRootEncryptionKey(password);
const { tag, encoding, ciphertext, iv } = crypto.encryption().symmetric().encryptWithRootEncryptionKey(password);
const encKeys = await generateUserSrpKeys(sanitizedEmail, password);
const userEnc = await userDAL.createUserEncryption(
+9 -6
View File
@@ -218,12 +218,15 @@ export const userServiceFactory = ({
throw new NotFoundError({ message: `Private key for user with ID '${userId}' not found` });
}
const privateKey = crypto.encryption().decryptWithRootEncryptionKey({
ciphertext: user.serverEncryptedPrivateKey,
tag: user.serverEncryptedPrivateKeyTag,
iv: user.serverEncryptedPrivateKeyIV,
keyEncoding: user.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
const privateKey = crypto
.encryption()
.symmetric()
.decryptWithRootEncryptionKey({
ciphertext: user.serverEncryptedPrivateKey,
tag: user.serverEncryptedPrivateKeyTag,
iv: user.serverEncryptedPrivateKeyIV,
keyEncoding: user.serverEncryptedPrivateKeyEncoding as SecretKeyEncoding
});
return privateKey;
};