From 5ff3b6747ad34103e88a4055c25e21fe5d00e15c Mon Sep 17 00:00:00 2001 From: S4kura0ne Date: Sun, 15 Sep 2019 15:21:53 +0800 Subject: [PATCH] fix wrong iv length (#109) --- index.js | 2 +- lib/blog-encrypt.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0e2e792..4cfbc1f 100644 --- a/index.js +++ b/index.js @@ -107,7 +107,7 @@ hexo.extend.filter.register('after_post_render', (data) => { log.info(`hexo-blog-encrypt: encrypting "${data.title.trim()}".`); const key = crypto.pbkdf2Sync(password, keySalt, 1024, 256/8, 'sha256'); - const iv = crypto.pbkdf2Sync(password, ivSalt, 512, 512, 'sha256'); + const iv = crypto.pbkdf2Sync(password, ivSalt, 512, 16, 'sha256'); const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); const hmac = crypto.createHmac('sha256', key); diff --git a/lib/blog-encrypt.js b/lib/blog-encrypt.js index 30a291c..60535e1 100644 --- a/lib/blog-encrypt.js +++ b/lib/blog-encrypt.js @@ -147,7 +147,7 @@ 'hash': 'SHA-256', 'salt': ivSalt.buffer, 'iterations': 512, - }, keyMaterial, 512 * 8); + }, keyMaterial, 16 * 8); } async function verifyContent(key, content) {