Skip to content
This repository was archived by the owner on Dec 29, 2023. It is now read-only.

Commit b49f23d

Browse files
authored
Use secure scrypt salted hashing instead of SHA-256. (NLnetLabs/krill#382) (#98)
1 parent ba18983 commit b49f23d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"ip6addr": "^0.2.3",
2525
"moment": "^2.27.0",
2626
"prismjs": "^1.21.0",
27+
"scryptsy": "^2.1.0",
2728
"typeface-lato": "^0.0.54",
2829
"typeface-source-code-pro": "^0.0.71",
2930
"vue": "^2.5.21",

src/views/Login.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</template>
6969

7070
<script>
71-
import sha256 from "crypto-js/sha256";
71+
import scrypt from "scryptsy";
7272
import router from "../router";
7373
import APIService from "@/services/APIService.js";
7474
@@ -189,9 +189,14 @@ export default {
189189
// Send a hash of the password to avoid storing a password on the server
190190
// that (shouldn't be but) might be the same password the user uses for
191191
// other systems.
192-
let hashedPassword = sha256(this.form.token);
192+
const cost_level = 13;
193+
const N = Math.pow(2, cost_level), r = 8, p = 1, dkLen = 32;
194+
let salt = "krill-lagosta-" + this.form.id;
195+
let pwBuf = this.form.token.normalize('NFKC');
196+
let saltBuf = salt.normalize('NFKC');
197+
let hashedPassword = scrypt(pwBuf, saltBuf, N, r, p, dkLen).toString('hex');
193198
APIService.login(hashedPassword, this.form.id).then((success) => {
194-
this.postLogin(success);
199+
this.postLogin(success)
195200
});
196201
} else {
197202
// Handle admin token based login

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7825,6 +7825,11 @@ schema-utils@^1.0.0:
78257825
ajv-errors "^1.0.0"
78267826
ajv-keywords "^3.1.0"
78277827

7828+
scrypt-js@^3.0.1:
7829+
version "3.0.1"
7830+
resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312"
7831+
integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==
7832+
78287833
scss-tokenizer@^0.2.3:
78297834
version "0.2.3"
78307835
resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"

0 commit comments

Comments
 (0)