Permalink
Browse files

Assume utf8 inputs for SMP

  • Loading branch information...
1 parent 442cb99 commit 4786e67124b2069ad0ee395cff16abb58372de2c @arlolra committed Feb 1, 2014
Showing with 15 additions and 5 deletions.
  1. +5 −0 lib/otr.js
  2. +6 −1 lib/sm.js
  3. +4 −4 test/spec/unit/sm.js
View
@@ -512,6 +512,11 @@
return this.error('Secret is required.')
if (!this.sm) this._smInit()
+
+ // utf8 inputs
+ secret = CryptoJS.enc.Utf8.parse(secret).toString(CryptoJS.enc.Latin1)
+ question = CryptoJS.enc.Utf8.parse(question).toString(CryptoJS.enc.Latin1)
+
this.sm.rcvSecret(secret, question)
}
View
@@ -61,7 +61,7 @@
sha256.update(CryptoJS.enc.Hex.parse(our ? this.our_fp : this.their_fp))
sha256.update(CryptoJS.enc.Hex.parse(our ? this.their_fp : this.our_fp))
sha256.update(CryptoJS.enc.Latin1.parse(this.ssid))
- sha256.update(CryptoJS.enc.Latin1.parse(secret)) // utf8?
+ sha256.update(CryptoJS.enc.Latin1.parse(secret))
var hash = sha256.finalize()
this.secret = HLP.bits2bigInt(hash.toString(CryptoJS.enc.Latin1))
}
@@ -170,6 +170,11 @@
this.smpstate = CONST.SMPSTATE_EXPECT0
+ // assume utf8 question
+ question = CryptoJS.enc.Latin1
+ .parse(question)
+ .toString(CryptoJS.enc.Utf8)
+
// invoke question
this.trigger('question', [question])
return
View
@@ -48,7 +48,7 @@ describe('SM', function () {
if (state === CONST.STATUS_AKE_SUCCESS) {
assert.equal(userB.msgstate, CONST.MSGSTATE_ENCRYPTED, 'Encrypted')
assert.equal(userA.msgstate, CONST.MSGSTATE_ENCRYPTED, 'Encrypted')
- userA.smpSecret('applesAndOranges')
+ userA.smpSecret('applesAndOranges utf8 äöüß')
}
})
@@ -68,7 +68,7 @@ describe('SM', function () {
userB.on('smp', function (type, data, act) {
switch (type) {
case 'question':
- userB.smpSecret('applesAndOranges')
+ userB.smpSecret('applesAndOranges utf8 äöüß')
break
case 'trust':
assert.ok(data, 'Trust A? false')
@@ -150,7 +150,7 @@ describe('SM', function () {
if (state === CONST.STATUS_AKE_SUCCESS) {
assert.equal(userB.msgstate, CONST.MSGSTATE_ENCRYPTED, 'Encrypted')
assert.equal(userA.msgstate, CONST.MSGSTATE_ENCRYPTED, 'Encrypted')
- userA.smpSecret('applesAndOranges', 'What is difference?')
+ userA.smpSecret('applesAndOranges', 'What is difference? utf8 äöüß')
}
})
@@ -159,7 +159,7 @@ describe('SM', function () {
userB.on('smp', function (type, data, act) {
switch (type) {
case 'question':
- assert.equal('What is difference?', data, type)
+ assert.equal('What is difference? utf8 äöüß', data, type)
userB.smpSecret('applesAndOranges')
break
case 'trust':

0 comments on commit 4786e67

Please sign in to comment.