1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-09 22:50:05 +00:00

Use JS cryptocore

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-01-11 20:22:55 +01:00
parent 7bdc430812
commit 9bd560a05a
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
5 changed files with 39 additions and 3 deletions

View file

@ -21,7 +21,10 @@ module.exports = {
plugins: ['vue'], plugins: ['vue'],
globals: { globals: {
Go: true, Go: true,
opensslDecrypt: true,
opensslEncrypt: true,
process: true, process: true,
sha256sum: true,
}, },
// add your custom rules here // add your custom rules here
rules: { rules: {

10
package-lock.json generated
View file

@ -6992,6 +6992,11 @@
"assert-plus": "^1.0.0" "assert-plus": "^1.0.0"
} }
}, },
"gibberish-aes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gibberish-aes/-/gibberish-aes-1.0.0.tgz",
"integrity": "sha1-9kHEWPuCLgrWHDwN6hWOC5Q+n8U="
},
"glob": { "glob": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
@ -11905,6 +11910,11 @@
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
}, },
"sha2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/sha2/-/sha2-1.0.2.tgz",
"integrity": "sha512-sQ1sFn+WN2weGkwwt25bllwocaJLyYeDrn/T221Bovc6XEHRf7NSn0KPoPQMV2+NT+RhJoStkdm4TrEGCXkKHA=="
},
"shallow-clone": { "shallow-clone": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz",

View file

@ -14,6 +14,8 @@
"axios": "^0.18.1", "axios": "^0.18.1",
"bootstrap-vue": "^2.2.0", "bootstrap-vue": "^2.2.0",
"bootswatch": "^4.4.1", "bootswatch": "^4.4.1",
"gibberish-aes": "^1.0.0",
"sha2": "^1.0.2",
"uuid": "^3.3.3", "uuid": "^3.3.3",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-clipboard2": "^0.2.1", "vue-clipboard2": "^0.2.1",

18
src/js_cryptocore.js Normal file
View file

@ -0,0 +1,18 @@
import GibberishAES from 'gibberish-aes/src/gibberish-aes.js'
import { SHA256 } from 'sha2'
const opensslDecrypt = (plaintext, password, callback) => {
callback(GibberishAES.enc(plaintext, password), null)
}
const opensslEncrypt = (ciphertext, password, callback) => {
callback(GibberishAES.dec(ciphertext, password), null)
}
const sha256sum = (plaintext, callback) => {
callback(SHA256(plaintext).toString('hex'))
}
window.opensslDecrypt = opensslDecrypt
window.opensslEncrypt = opensslEncrypt
window.sha256sum = sha256sum

View file

@ -35,9 +35,12 @@ Vue.component('fa-icon', FontAwesomeIcon)
axios.defaults.baseURL = 'v2' axios.defaults.baseURL = 'v2'
const go = new Go() /*
WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject) * const go = new Go()
.then(async obj => await go.run(obj.instance)) * WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject)
* .then(async obj => await go.run(obj.instance))
*/
import './js_cryptocore.js' // JS alternative
window.instance = new Vue({ window.instance = new Vue({
mounted: () => store.dispatch('reload_users'), mounted: () => store.dispatch('reload_users'),