mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 20:25:43 +00:00
Checkpoint adding crypto metadata
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
} from '../errors';
|
||||
import {
|
||||
ALGORITHM_AES_256_GCM,
|
||||
BLOCK_SIZE_BYTES_32,
|
||||
NONCE_BYTES_SIZE,
|
||||
BLOCK_SIZE_BYTES_16
|
||||
} from '../../variables';
|
||||
import { validateEncryptionKey } from '../../validation';
|
||||
@@ -112,7 +112,7 @@ const encryptSymmetric = ({
|
||||
}: IEncryptSymmetricInput): IEncryptSymmetricOutput => {
|
||||
validateEncryptionKey(key);
|
||||
|
||||
const iv = crypto.randomBytes(BLOCK_SIZE_BYTES_32);
|
||||
const iv = crypto.randomBytes(NONCE_BYTES_SIZE);
|
||||
const secretKey = crypto.createSecretKey(key, 'base64');
|
||||
const cipher = crypto.createCipheriv(ALGORITHM_AES_256_GCM, secretKey, iv);
|
||||
|
||||
@@ -169,7 +169,7 @@ const decryptSymmetric = ({
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} obj.plaintext - (utf8) plaintext to encrypt
|
||||
* @param {String} obj.key - (base64) 256-bit key
|
||||
* @param {String} obj.key - (hex) 128-bit key
|
||||
* @returns {Object} obj
|
||||
* @returns {String} obj.ciphertext (base64) ciphertext
|
||||
* @returns {String} obj.iv (base64) iv
|
||||
|
||||
@@ -114,7 +114,6 @@ export const backfillEncryptionMetadata = async () => {
|
||||
{
|
||||
$set: {
|
||||
algorithm: ALGORITHM_AES_256_GCM,
|
||||
keySize: 256,
|
||||
keyEncoding: ENCODING_SCHEME_UTF8
|
||||
}
|
||||
}
|
||||
@@ -136,7 +135,6 @@ export const backfillEncryptionMetadata = async () => {
|
||||
{
|
||||
$set: {
|
||||
algorithm: ALGORITHM_AES_256_GCM,
|
||||
keySize: 256,
|
||||
keyEncoding: ENCODING_SCHEME_UTF8
|
||||
}
|
||||
}
|
||||
@@ -158,7 +156,6 @@ export const backfillEncryptionMetadata = async () => {
|
||||
{
|
||||
$set: {
|
||||
algorithm: ALGORITHM_AES_256_GCM,
|
||||
keySize: 256,
|
||||
keyEncoding: ENCODING_SCHEME_UTF8
|
||||
}
|
||||
}
|
||||
@@ -167,12 +164,20 @@ export const backfillEncryptionMetadata = async () => {
|
||||
// backfill integration auth encryption metadata
|
||||
await IntegrationAuth.updateMany(
|
||||
{
|
||||
|
||||
algorithm: {
|
||||
$exists: false
|
||||
},
|
||||
keySize: {
|
||||
$exists: false
|
||||
},
|
||||
keyEncoding: {
|
||||
$exists: false
|
||||
}
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
algorithm: ALGORITHM_AES_256_GCM,
|
||||
|
||||
keyEncoding: ENCODING_SCHEME_UTF8
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user