hex all the strings. closes #51
This commit is contained in:
Родитель
82e006edb3
Коммит
cdfecb1226
|
@ -80,7 +80,7 @@ exports.create = function(data, cb) {
|
|||
params: data.params,
|
||||
verifier: data.verifier,
|
||||
salt: data.salt,
|
||||
kA: key.toString('base64'),
|
||||
kA: key.toString('hex'),
|
||||
wrapKb: data.wrapKb,
|
||||
resetTokens: {},
|
||||
signTokens: {}
|
||||
|
@ -214,9 +214,9 @@ exports.getToken2 = function (sessionId, tokenType, A, M1, cb) {
|
|||
function(result, next) {
|
||||
token = result.token;
|
||||
kv.cache.set(
|
||||
result.keys.tokenId.toString('base64') + '/hawk',
|
||||
result.keys.tokenId.toString('hex') + '/hawk',
|
||||
{
|
||||
key: result.keys.reqHMACkey.toString('base64'),
|
||||
key: result.keys.reqHMACkey.toString('hex'),
|
||||
algorithm: 'sha256',
|
||||
uid: uid,
|
||||
token: result.token.toString('hex')
|
||||
|
@ -240,13 +240,13 @@ exports.getToken2 = function (sessionId, tokenType, A, M1, cb) {
|
|||
{
|
||||
bundle: util.srpSignTokenBundle(
|
||||
{
|
||||
kA: Buffer(user.kA, 'base64'),
|
||||
wrapKb: user.wrapKb ? Buffer(user.wrapKb, 'base64') : emptyKey,
|
||||
kA: Buffer(user.kA, 'hex'),
|
||||
wrapKb: user.wrapKb ? Buffer(user.wrapKb, 'hex') : emptyKey,
|
||||
token: token,
|
||||
hmacKey: keys.respHMACkey,
|
||||
encKey: keys.respXORkey
|
||||
}
|
||||
).toString('base64')
|
||||
).toString('hex')
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ exports.getResetToken = function(accountToken, cb) {
|
|||
};
|
||||
|
||||
exports.resetAccount = function(resetToken, bundle, cb) {
|
||||
var cyphertext = Buffer(bundle, 'base64');
|
||||
var cyphertext = Buffer(bundle, 'hex');
|
||||
var userId, user, data;
|
||||
|
||||
console.log('cypher!!!', cyphertext.toString('hex'));
|
||||
|
@ -362,8 +362,8 @@ exports.resetAccount = function(resetToken, bundle, cb) {
|
|||
console.log('ver!!!', cleartext.slice(64).toString('hex'));
|
||||
|
||||
data = {
|
||||
kA: cleartext.slice(0, 32).toString('base64'),
|
||||
wrapKb: cleartext.slice(32, 64).toString('base64'),
|
||||
kA: cleartext.slice(0, 32).toString('hex'),
|
||||
wrapKb: cleartext.slice(32, 64).toString('hex'),
|
||||
verifier: cleartext.slice(64).toString('hex')
|
||||
};
|
||||
console.log('data', data);
|
||||
|
|
|
@ -285,7 +285,7 @@ function resetAccount(request) {
|
|||
|
||||
function getEntropy(request) {
|
||||
crypto.randomBytes(32, function(err, buf) {
|
||||
request.reply(buf.toString('base64'));
|
||||
request.reply(buf.toString('hex'));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ TestClient.prototype.getToken2 = function (tokenType, session, email, password,
|
|||
K,
|
||||
tokenTypes[tokenType].context,
|
||||
function (err, keys) {
|
||||
var blob = Buffer(json.bundle, 'base64');
|
||||
var blob = Buffer(json.bundle, 'hex');
|
||||
var cyphertext = blob.slice(0, blob.length - 32);
|
||||
var hmac = blob.slice(blob.length - 32, blob.length);
|
||||
|
||||
|
@ -273,8 +273,8 @@ TestClient.prototype.getToken2 = function (tokenType, session, email, password,
|
|||
.xor(bigint.fromBuffer(keys.respXORkey))
|
||||
.toBuffer();
|
||||
var result = {
|
||||
kA: cleartext.slice(0, 32).toString('base64'),
|
||||
wrapKb: cleartext.slice(32, 64).toString('base64'),
|
||||
kA: cleartext.slice(0, 32).toString('hex'),
|
||||
wrapKb: cleartext.slice(32, 64).toString('hex'),
|
||||
token: cleartext.slice(64).toString('hex')
|
||||
};
|
||||
cb(null, result);
|
||||
|
@ -289,8 +289,8 @@ TestClient.prototype.sign = function (publicKey, duration, signToken, hashPayloa
|
|||
Buffer(signToken, 'hex'),
|
||||
function (err, keys) {
|
||||
var credentials = {
|
||||
id: keys.tokenId.toString('base64'),
|
||||
key: keys.reqHMACkey.toString('base64'),
|
||||
id: keys.tokenId.toString('hex'),
|
||||
key: keys.reqHMACkey.toString('hex'),
|
||||
algorithm: 'sha256'
|
||||
};
|
||||
var payload = {
|
||||
|
@ -330,7 +330,7 @@ TestClient.prototype.resetAccount = function (resetToken, email, password, kA, k
|
|||
var salt = crypto.randomBytes(32);
|
||||
var verifier = srp.getv(salt, email, password, srpParams['2048'].N, srpParams['2048'].g, alg);
|
||||
console.log('ver??', verifier.toString(16));
|
||||
var cleartext = Buffer.concat([Buffer(kA, 'base64'), Buffer(kB, 'base64'), verifier.toBuffer()]);
|
||||
var cleartext = Buffer.concat([Buffer(kA, 'hex'), Buffer(kB, 'hex'), verifier.toBuffer()]);
|
||||
|
||||
util.resetKeys(
|
||||
Buffer(resetToken, 'hex'),
|
||||
|
@ -343,12 +343,12 @@ TestClient.prototype.resetAccount = function (resetToken, email, password, kA, k
|
|||
.toBuffer();
|
||||
|
||||
var credentials = {
|
||||
id: keys.tokenId.toString('base64'),
|
||||
key: keys.reqHMACkey.toString('base64'),
|
||||
id: keys.tokenId.toString('hex'),
|
||||
key: keys.reqHMACkey.toString('hex'),
|
||||
algorithm: 'sha256'
|
||||
};
|
||||
var payload = {
|
||||
bundle: cyphertext.toString('base64')
|
||||
bundle: cyphertext.toString('hex')
|
||||
};
|
||||
var verify = {
|
||||
credentials: credentials,
|
||||
|
|
|
@ -12,9 +12,9 @@ var testClient = new helpers.TestClient();
|
|||
var TEST_EMAIL = 'foo@example.com';
|
||||
var TEST_PASSWORD = 'foo';
|
||||
var TEST_PASSWORD_NEW = 'I like pie.';
|
||||
var TEST_WRAPKB = crypto.randomBytes(32).toString('base64');
|
||||
var TEST_WRAPKB_NEW = crypto.randomBytes(32).toString('base64');
|
||||
var TEST_KA_NEW = crypto.randomBytes(32).toString('base64');
|
||||
var TEST_WRAPKB = crypto.randomBytes(32).toString('hex');
|
||||
var TEST_WRAPKB_NEW = crypto.randomBytes(32).toString('hex');
|
||||
var TEST_KA_NEW = crypto.randomBytes(32).toString('hex');
|
||||
|
||||
describe('user', function() {
|
||||
var session, pubkey, signToken, resetToken;
|
||||
|
@ -362,7 +362,7 @@ describe('user', function() {
|
|||
try {
|
||||
entropy = res.result;
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(entropy.length, 44);
|
||||
assert.equal(Buffer(entropy, 'hex').length, 32);
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче