api/crypto: use buffers for salt directly instead of hex strings
This commit is contained in:
parent
93e6344fc7
commit
2d6d406f48
2 changed files with 3 additions and 3 deletions
|
@ -3,7 +3,7 @@ import { createHmac, createCipheriv, createDecipheriv, randomBytes } from "crypt
|
||||||
const algorithm = "aes256";
|
const algorithm = "aes256";
|
||||||
|
|
||||||
export function generateSalt() {
|
export function generateSalt() {
|
||||||
return randomBytes(64).toString('hex');
|
return randomBytes(64);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generateHmac(str, salt) {
|
export function generateHmac(str, salt) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { setMaxListeners } from "node:events";
|
||||||
|
|
||||||
import { env, tunnelPort } from "../config.js";
|
import { env, tunnelPort } from "../config.js";
|
||||||
import { closeRequest } from "./shared.js";
|
import { closeRequest } from "./shared.js";
|
||||||
import { decryptStream, encryptStream, generateHmac } from "../misc/crypto.js";
|
import { decryptStream, encryptStream, generateHmac, generateSalt } from "../misc/crypto.js";
|
||||||
|
|
||||||
// optional dependency
|
// optional dependency
|
||||||
const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
|
const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
|
||||||
|
@ -15,7 +15,7 @@ const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
|
||||||
const streamCache = new Store('streams');
|
const streamCache = new Store('streams');
|
||||||
|
|
||||||
const internalStreamCache = new Map();
|
const internalStreamCache = new Map();
|
||||||
const hmacSalt = randomBytes(64).toString('hex');
|
const hmacSalt = generateSalt();
|
||||||
|
|
||||||
export function createStream(obj) {
|
export function createStream(obj) {
|
||||||
const streamID = nanoid(),
|
const streamID = nanoid(),
|
||||||
|
|
Loading…
Reference in a new issue