From e20fc6deacf302f800856e76cbeb1b4e58bdb9c3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 9 Jun 2012 16:15:05 -0400 Subject: [PATCH] Add core.{html,js} to start generating secure keys --- core.html | 48 ++++++++++++++++++++++++++++++++++++++++ core.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 core.html create mode 100644 core.js diff --git a/core.html b/core.html new file mode 100644 index 0000000..a8f07b6 --- /dev/null +++ b/core.html @@ -0,0 +1,48 @@ + + + + Skeleton Key + + + + + +
+
    +
  1. + + +
  2. + +
  3. + + +
  4. + +
  5. + + +
  6. + +
  7. + + +
  8. + +
  9. + +
  10. +
+
+ + + + diff --git a/core.js b/core.js new file mode 100644 index 0000000..171ede1 --- /dev/null +++ b/core.js @@ -0,0 +1,66 @@ +/* Copyright (c) 2012 Robert Sesek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * SkeletonKey is view controller for generating secure passwords. + * + * @param {HTMLDocument} doc The document on which to operate. + */ +var SkeletonKey = SkeletonKey || function(doc) { + this._master = doc.getElementById('master'); + this._sitekey = doc.getElementById('sitekey'); + this._username = doc.getElementById('username'); + this._password = doc.getElementById('password'); + this._generateButton = doc.getElementById('generate'); + this._init(); +}; + +/** + * The number of iterations to perform in PBKDF2. + * @const {int} + */ +SkeletonKey.prototype.ITERATIONS = 1000; +/** + * The size of the key, in bytes. + * @const {int} + */ +SkeletonKey.prototype.KEYSIZE = 256/32; + +/** + * Initializes event handlers for the page. + * @private + */ +SkeletonKey.prototype._init = function() { + this._generateButton.onclick = this._onGenerate.bind(this); +}; + +/** + * Event handler for generating a new password. + * @param {Event} e + * @private + */ +SkeletonKey.prototype._onGenerate = function(e) { + var salt = this._username.value + '@' + this._sitekey.value; + // |key| is a WordArray of 32-bit words. + var key = CryptoJS.PBKDF2(this._master.value, salt, + {keySize: this.KEYSIZE, iterations: this.ITERATIONS}); + console.log(key); +}; -- 2.43.5