Skip to content

Commit e4ca4cc

Browse files
committed
Remove dependency on gotrax - no point anymore
1 parent 5e2f2a7 commit e4ca4cc

27 files changed

+127
-324
lines changed

Gopkg.lock

-15
This file was deleted.

Gopkg.toml

-34
This file was deleted.

ake.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"io"
77
"math/big"
88
"time"
9-
10-
"github.com/coyim/gotrax"
119
)
1210

1311
var dontIgnoreFastRepeatQueryMessage = "false"
@@ -72,10 +70,10 @@ func (c *Conversation) generateEncryptedSignature(key *akeKeys) ([]byte, error)
7270
return nil, err
7371
}
7472

75-
return gotrax.AppendData(nil, xb), nil
73+
return AppendData(nil, xb), nil
7674
}
7775
func appendAll(one, two *big.Int, publicKey PublicKey, keyID uint32) []byte {
78-
return gotrax.AppendWord(append(gotrax.AppendMPI(gotrax.AppendMPI(nil, one), two), publicKey.serialize()...), keyID)
76+
return AppendWord(append(AppendMPI(AppendMPI(nil, one), two), publicKey.serialize()...), keyID)
7977
}
8078

8179
func fixedSize(s int, v []byte) []byte {
@@ -89,7 +87,7 @@ func fixedSize(s int, v []byte) []byte {
8987

9088
func (c *Conversation) calcXb(key *akeKeys, mb []byte) ([]byte, error) {
9189
xb := c.ourCurrentKey.PublicKey().serialize()
92-
xb = gotrax.AppendWord(xb, c.ake.keys.ourKeyID)
90+
xb = AppendWord(xb, c.ake.keys.ourKeyID)
9391

9492
sigb, err := c.ourCurrentKey.Sign(c.rand(), mb)
9593
if err == io.ErrUnexpectedEOF || err == io.EOF {
@@ -126,15 +124,15 @@ func (c *Conversation) dhCommitMessage() ([]byte, error) {
126124
}
127125

128126
// this can't return an error, since ake.r is of a fixed size that is always correct
129-
c.ake.encryptedGx, _ = encrypt(c.ake.r[:], gotrax.AppendMPI(nil, c.ake.ourPublicValue))
127+
c.ake.encryptedGx, _ = encrypt(c.ake.r[:], AppendMPI(nil, c.ake.ourPublicValue))
130128

131129
return c.serializeDHCommit(c.ake.ourPublicValue), nil
132130
}
133131

134132
func (c *Conversation) serializeDHCommit(public *big.Int) []byte {
135133
dhCommitMsg := dhCommit{
136134
encryptedGx: c.ake.encryptedGx,
137-
yhashedGx: c.version.hash2(gotrax.AppendMPI(nil, public)),
135+
yhashedGx: c.version.hash2(AppendMPI(nil, public)),
138136
}
139137
return dhCommitMsg.serialize()
140138
}
@@ -310,7 +308,7 @@ func (c *Conversation) checkedSignatureVerification(mb, sig []byte) error {
310308
}
311309

312310
func verifyEncryptedSignatureMAC(encryptedSig []byte, theirMAC []byte, keys *akeKeys, v otrVersion) error {
313-
tomac := gotrax.AppendData(nil, encryptedSig)
311+
tomac := AppendData(nil, encryptedSig)
314312

315313
myMAC := sumHMAC(keys.m2, tomac, v)[:v.truncateLength()]
316314

@@ -325,7 +323,7 @@ func (c *Conversation) parseTheirKey(key []byte) (sig []byte, keyID uint32, err
325323
var rest []byte
326324
var ok, ok2 bool
327325
rest, ok, c.theirKey = ParsePublicKey(key)
328-
sig, keyID, ok2 = gotrax.ExtractWord(rest)
326+
sig, keyID, ok2 = ExtractWord(rest)
329327
if !(ok && ok2) {
330328
return nil, 0, errCorruptEncryptedSignature
331329
}
@@ -364,7 +362,7 @@ func (c *Conversation) processEncryptedSig(encryptedSig []byte, theirMAC []byte,
364362
}
365363

366364
func extractGx(decryptedGx []byte) (*big.Int, error) {
367-
newData, gx, ok := gotrax.ExtractMPI(decryptedGx)
365+
newData, gx, ok := ExtractMPI(decryptedGx)
368366
if !ok || len(newData) > 0 {
369367
return gx, newOtrError("gx corrupt after decryption")
370368
}

ake_test.go

+21-23
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"io"
66
"math/big"
77
"testing"
8-
9-
"github.com/coyim/gotrax"
108
)
119

1210
var (
@@ -26,8 +24,8 @@ func Test_dhCommitMessage(t *testing.T) {
2624
c.ourCurrentKey = bobPrivateKey
2725

2826
var out []byte
29-
out = gotrax.AppendData(out, encryptedFixedGX())
30-
out = gotrax.AppendData(out, hashedFixedGX())
27+
out = AppendData(out, encryptedFixedGX())
28+
out = AppendData(out, hashedFixedGX())
3129

3230
result, err := c.dhCommitMessage()
3331
assertEquals(t, err, nil)
@@ -42,7 +40,7 @@ func Test_dhKeyMessage(t *testing.T) {
4240
expectedGyValue := bnFromHex("075dfab5a1eab059052d0ad881c4938d52669630d61833a367155d67d03a457f619683d0fa829781e974fd24f6865e8128a9312a167b77326a87dea032fc31784d05b18b9cbafebe162ae9b5369f8b0c5911cf1be757f45f2a674be5126a714a6366c28086b3c7088911dcc4e5fb1481ad70a5237b8e4a6aff4954c2ca6df338b9f08691e4c0defe12689b37d4df30ddef2687f789fcf623c5d0cf6f09b7e5e69f481d5fd1b24a77636fb676e6d733d129eb93e81189340233044766a36eb07d")
4341

4442
var out []byte
45-
out = gotrax.AppendMPI(out, expectedGyValue)
43+
out = AppendMPI(out, expectedGyValue)
4644

4745
result, err := c.dhKeyMessage()
4846
assertEquals(t, err, nil)
@@ -72,7 +70,7 @@ func Test_revealSigMessage(t *testing.T) {
7270
expedctedMACSignature := bytesFromHex("8e6e5ef63a4e8d6aa2cfb1c5fe1831498862f69d7de32af4f9895180e4b494e6")
7371

7472
var out []byte
75-
out = gotrax.AppendData(out, c.ake.r[:])
73+
out = AppendData(out, c.ake.r[:])
7674
out = append(out, expectedEncryptedSignature...)
7775
out = append(out, expedctedMACSignature[:20]...)
7876

@@ -100,7 +98,7 @@ func Test_processDHKey(t *testing.T) {
10098
c.initAKE()
10199
c.ake.theirPublicValue = fixedGY()
102100

103-
msg := gotrax.AppendMPI(nil, c.ake.theirPublicValue)
101+
msg := AppendMPI(nil, c.ake.theirPublicValue)
104102

105103
isSame, err := c.processDHKey(msg)
106104
assertEquals(t, err, nil)
@@ -112,7 +110,7 @@ func Test_processDHKeyNotSame(t *testing.T) {
112110
c.initAKE()
113111
c.ake.theirPublicValue = fixedGY()
114112

115-
msg := gotrax.AppendMPI(nil, fixedGX())
113+
msg := AppendMPI(nil, fixedGX())
116114

117115
isSame, err := c.processDHKey(msg)
118116
assertEquals(t, err, nil)
@@ -126,7 +124,7 @@ func Test_processDHKeyHavingError(t *testing.T) {
126124
c.initAKE()
127125
c.ake.theirPublicValue = fixedGY()
128126

129-
msg := gotrax.AppendMPI(nil, invalidGy)
127+
msg := AppendMPI(nil, invalidGy)
130128

131129
isSame, err := c.processDHKey(msg)
132130
assertEquals(t, err.Error(), "otr: DH value out of range")
@@ -142,7 +140,7 @@ func Test_processEncryptedSig(t *testing.T) {
142140
c.ake.keys.ourKeyID = 1
143141
c.calcAKEKeys(c.calcDHSharedSecret())
144142

145-
_, encryptedSig, _ := gotrax.ExtractData(bytesFromHex("000001d2dda2d4ef365711c172dad92804b201fcd2fdd6444568ebf0844019fb65ca4f5f57031936f9a339e08bfd4410905ab86c5d6f73e6c94de6a207f373beff3f7676faee7b1d3be21e630fe42e95db9d4ac559252bff530481301b590e2163b99bde8aa1b07448bf7252588e317b0ba2fc52f85a72a921ba757785b949e5e682341d98800aa180aa0bd01f51180d48260e4358ffae72a97f652f02eb6ae3bc6a25a317d0ca5ed0164a992240baac8e043f848332d22c10a46d12c745dc7b1b0ee37fd14614d4b69d500b8ce562040e3a4bfdd1074e2312d3e3e4c68bd15d70166855d8141f695b21c98c6055a5edb9a233925cf492218342450b806e58b3a821e5d1d2b9c6b9cbcba263908d7190a3428ace92572c064a328f86fa5b8ad2a9c76d5b9dcaeae5327f545b973795f7c655248141c2f82db0a2045e95c1936b726d6474f50283289e92ab5c7297081a54b9e70fce87603506dedd6734bab3c1567ee483cd4bcb0e669d9d97866ca274f178841dafc2acfdcd10cb0e2d07db244ff4b1d23afe253831f142083d912a7164a3425f82c95675298cf3c5eb3e096bbc95e44ecffafbb585738723c0adbe11f16c311a6cddde630b9c304717ce5b09247d482f32709ea71ced16ba930a554f9949c1acbecf"))
143+
_, encryptedSig, _ := ExtractData(bytesFromHex("000001d2dda2d4ef365711c172dad92804b201fcd2fdd6444568ebf0844019fb65ca4f5f57031936f9a339e08bfd4410905ab86c5d6f73e6c94de6a207f373beff3f7676faee7b1d3be21e630fe42e95db9d4ac559252bff530481301b590e2163b99bde8aa1b07448bf7252588e317b0ba2fc52f85a72a921ba757785b949e5e682341d98800aa180aa0bd01f51180d48260e4358ffae72a97f652f02eb6ae3bc6a25a317d0ca5ed0164a992240baac8e043f848332d22c10a46d12c745dc7b1b0ee37fd14614d4b69d500b8ce562040e3a4bfdd1074e2312d3e3e4c68bd15d70166855d8141f695b21c98c6055a5edb9a233925cf492218342450b806e58b3a821e5d1d2b9c6b9cbcba263908d7190a3428ace92572c064a328f86fa5b8ad2a9c76d5b9dcaeae5327f545b973795f7c655248141c2f82db0a2045e95c1936b726d6474f50283289e92ab5c7297081a54b9e70fce87603506dedd6734bab3c1567ee483cd4bcb0e669d9d97866ca274f178841dafc2acfdcd10cb0e2d07db244ff4b1d23afe253831f142083d912a7164a3425f82c95675298cf3c5eb3e096bbc95e44ecffafbb585738723c0adbe11f16c311a6cddde630b9c304717ce5b09247d482f32709ea71ced16ba930a554f9949c1acbecf"))
146144
macSignature := bytesFromHex("8e6e5ef63a4e8d6aa2cfb1c5fe1831498862f69d7de32af4f9895180e4b494e6")
147145
err := c.processEncryptedSig(encryptedSig, macSignature[:20], &c.ake.revealKey)
148146
assertEquals(t, err, nil)
@@ -153,7 +151,7 @@ func Test_processEncryptedSigWithBadSignatureMACError(t *testing.T) {
153151
c := Conversation{version: otrV3{}}
154152
c.initAKE()
155153

156-
_, encryptedSig, _ := gotrax.ExtractData(bytesFromHex("000001b2dda2d4ef365711c172dad92804b201fcd2fdd6444568ebf0844019fb65ca4f5f57031936f9a339e08bfd4410905ab86c5d6f73e6c94de6a207f373beff3f7676faee7b1d3be21e630fe42e95db9d4ac559252bff530481301b590e2163b99bde8aa1b07448bf7252588e317b0ba2fc52f85a72a921ba757785b949e5e682341d98800aa180aa0bd01f51180d48260e4358ffae72a97f652f02eb6ae3bc6a25a317d0ca5ed0164a992240baac8e043f848332d22c10a46d12c745dc7b1b0ee37fd14614d4b69d500b8ce562040e3a4bfdd1074e2312d3e3e4c68bd15d70166855d8141f695b21c98c6055a5edb9a233925cf492218342450b806e58b3a821e5d1d2b9c6b9cbcba263908d7190a3428ace92572c064a328f86fa5b8ad2a9c76d5b9dcaeae5327f545b973795f7c655248141c2f82db0a2045e95c1936b726d6474f50283289e92ab5c7297081a54b9e70fce87603506dedd6734bab3c1567ee483cd4bcb0e669d9d97866ca274f178841dafc2acfdcd10cb0e2d07db244ff4b1d23afe253831f142083d912a7164a3425f82c95675298cf3c5eb3e096bbc95e44ecffafbb585738723c0adbe11f16c311a6cddde630b9c304717ce5b09247d482f32709ea71ced16ba930a554f9949c1acbecf"))
154+
_, encryptedSig, _ := ExtractData(bytesFromHex("000001b2dda2d4ef365711c172dad92804b201fcd2fdd6444568ebf0844019fb65ca4f5f57031936f9a339e08bfd4410905ab86c5d6f73e6c94de6a207f373beff3f7676faee7b1d3be21e630fe42e95db9d4ac559252bff530481301b590e2163b99bde8aa1b07448bf7252588e317b0ba2fc52f85a72a921ba757785b949e5e682341d98800aa180aa0bd01f51180d48260e4358ffae72a97f652f02eb6ae3bc6a25a317d0ca5ed0164a992240baac8e043f848332d22c10a46d12c745dc7b1b0ee37fd14614d4b69d500b8ce562040e3a4bfdd1074e2312d3e3e4c68bd15d70166855d8141f695b21c98c6055a5edb9a233925cf492218342450b806e58b3a821e5d1d2b9c6b9cbcba263908d7190a3428ace92572c064a328f86fa5b8ad2a9c76d5b9dcaeae5327f545b973795f7c655248141c2f82db0a2045e95c1936b726d6474f50283289e92ab5c7297081a54b9e70fce87603506dedd6734bab3c1567ee483cd4bcb0e669d9d97866ca274f178841dafc2acfdcd10cb0e2d07db244ff4b1d23afe253831f142083d912a7164a3425f82c95675298cf3c5eb3e096bbc95e44ecffafbb585738723c0adbe11f16c311a6cddde630b9c304717ce5b09247d482f32709ea71ced16ba930a554f9949c1acbecf"))
157155
macSignature := bytesFromHex("8e6e5ef63a4e8d6aa2cfb1c5fe1831498862f69d7de32af4f9895180e4b494e6")
158156
err := c.processEncryptedSig(encryptedSig, macSignature[:20], &c.ake.revealKey)
159157
assertEquals(t, err.Error(), "otr: bad signature MAC in encrypted signature")
@@ -172,7 +170,7 @@ func Test_processEncryptedSigWithBadSignatureError(t *testing.T) {
172170
s := c.calcDHSharedSecret()
173171
c.calcAKEKeys(s)
174172

175-
_, encryptedSig, _ := gotrax.ExtractData(bytesFromHex("000001d2dda2d4ef365711c172dad92804b201fcd2fdd6444568ebf0844019fb65ca4f5f57031936f9a339e08bfd4410905ab86c5d6f73e6c94de6a207f373beff3f7676faee7b1d3be21e630fe42e95db9d4ac559252bff530481301b590e2163b99bde8aa1b07448bf7252588e317b0ba2fc52f85a72a921ba757785b949e5e682341d98800aa180aa0bd01f51180d48260e4358ffae72a97f652f02eb6ae3bc6a25a317d0ca5ed0164a992240baac8e043f848332d22c10a46d12c745dc7b1b0ee37fd14614d4b69d500b8ce562040e3a4bfdd1074e2312d3e3e4c68bd15d70166855d8141f695b21c98c6055a5edb9a233925cf492218342450b806e58b3a821e5d1d2b9c6b9cbcba263908d7190a3428ace92572c064a328f86fa5b8ad2a9c76d5b9dcaeae5327f545b973795f7c655248141c2f82db0a2045e95c1936b726d6474f50283289e92ab5c7297081a54b9e70fce87603506dedd6734bab3c1567ee483cd4bcb0e669d9d97866ca274f178841dafc2acfdcd10cb0e2d07db244ff4b1d23afe253831f142083d912a7164a3425f82c95675298cf3c5eb3e096bbc95e44ecffafbb585738723c0adbe11f16c311a6cddde630b9c304717ce5b09247d482f32709ea71ced16ba930a554f9949c1acbeca"))
173+
_, encryptedSig, _ := ExtractData(bytesFromHex("000001d2dda2d4ef365711c172dad92804b201fcd2fdd6444568ebf0844019fb65ca4f5f57031936f9a339e08bfd4410905ab86c5d6f73e6c94de6a207f373beff3f7676faee7b1d3be21e630fe42e95db9d4ac559252bff530481301b590e2163b99bde8aa1b07448bf7252588e317b0ba2fc52f85a72a921ba757785b949e5e682341d98800aa180aa0bd01f51180d48260e4358ffae72a97f652f02eb6ae3bc6a25a317d0ca5ed0164a992240baac8e043f848332d22c10a46d12c745dc7b1b0ee37fd14614d4b69d500b8ce562040e3a4bfdd1074e2312d3e3e4c68bd15d70166855d8141f695b21c98c6055a5edb9a233925cf492218342450b806e58b3a821e5d1d2b9c6b9cbcba263908d7190a3428ace92572c064a328f86fa5b8ad2a9c76d5b9dcaeae5327f545b973795f7c655248141c2f82db0a2045e95c1936b726d6474f50283289e92ab5c7297081a54b9e70fce87603506dedd6734bab3c1567ee483cd4bcb0e669d9d97866ca274f178841dafc2acfdcd10cb0e2d07db244ff4b1d23afe253831f142083d912a7164a3425f82c95675298cf3c5eb3e096bbc95e44ecffafbb585738723c0adbe11f16c311a6cddde630b9c304717ce5b09247d482f32709ea71ced16ba930a554f9949c1acbeca"))
176174
macSignature := bytesFromHex("741f14776485e6c593928fd859afe1ab4896f1e6")
177175
err := c.processEncryptedSig(encryptedSig, macSignature[:20], &c.ake.revealKey)
178176
assertEquals(t, err.Error(), "otr: bad signature in encrypted signature")
@@ -297,9 +295,9 @@ func Test_encrypt(t *testing.T) {
297295
assertEquals(t, b, 16)
298296
assertEquals(t, err, nil)
299297

300-
encryptedGx, err := encrypt(c.ake.r[:], gotrax.AppendMPI(nil, c.ake.theirPublicValue))
298+
encryptedGx, err := encrypt(c.ake.r[:], AppendMPI(nil, c.ake.theirPublicValue))
301299
assertEquals(t, err, nil)
302-
assertDeepEquals(t, len(encryptedGx), len(gotrax.AppendMPI([]byte{}, c.ake.theirPublicValue)))
300+
assertDeepEquals(t, len(encryptedGx), len(AppendMPI([]byte{}, c.ake.theirPublicValue)))
303301
}
304302

305303
func Test_decrypt(t *testing.T) {
@@ -312,34 +310,34 @@ func Test_decrypt(t *testing.T) {
312310
assertEquals(t, b, 16)
313311
assertEquals(t, err, nil)
314312

315-
encryptedGx, _ := encrypt(c.ake.r[:], gotrax.AppendMPI(nil, c.ake.theirPublicValue))
313+
encryptedGx, _ := encrypt(c.ake.r[:], AppendMPI(nil, c.ake.theirPublicValue))
316314
decryptedGx := encryptedGx
317315
err = decrypt(c.ake.r[:], decryptedGx, encryptedGx)
318316

319317
assertEquals(t, err, nil)
320-
assertDeepEquals(t, decryptedGx, gotrax.AppendMPI([]byte{}, c.ake.theirPublicValue))
318+
assertDeepEquals(t, decryptedGx, AppendMPI([]byte{}, c.ake.theirPublicValue))
321319
}
322320

323321
func Test_checkDecryptedGxWithoutError(t *testing.T) {
324-
hashedGx := otrV3{}.hash2(gotrax.AppendMPI([]byte{}, fixedGX()))
325-
err := checkDecryptedGx(gotrax.AppendMPI([]byte{}, fixedGX()), hashedGx[:], otrV3{})
322+
hashedGx := otrV3{}.hash2(AppendMPI([]byte{}, fixedGX()))
323+
err := checkDecryptedGx(AppendMPI([]byte{}, fixedGX()), hashedGx[:], otrV3{})
326324
assertDeepEquals(t, err, nil)
327325
}
328326

329327
func Test_checkDecryptedGxWithError(t *testing.T) {
330-
hashedGx := otrV3{}.hash2(gotrax.AppendMPI([]byte{}, fixedGY()))
331-
err := checkDecryptedGx(gotrax.AppendMPI([]byte{}, fixedGX()), hashedGx[:], otrV3{})
328+
hashedGx := otrV3{}.hash2(AppendMPI([]byte{}, fixedGY()))
329+
err := checkDecryptedGx(AppendMPI([]byte{}, fixedGX()), hashedGx[:], otrV3{})
332330
assertDeepEquals(t, err.Error(), "otr: bad commit MAC in reveal signature message")
333331
}
334332

335333
func Test_extractGxWithoutError(t *testing.T) {
336-
gx, err := extractGx(gotrax.AppendMPI([]byte{}, fixedGX()))
334+
gx, err := extractGx(AppendMPI([]byte{}, fixedGX()))
337335
assertDeepEquals(t, err, nil)
338336
assertDeepEquals(t, gx, fixedGX())
339337
}
340338

341339
func Test_extractGxWithCorruptError(t *testing.T) {
342-
gx, err := extractGx(gotrax.AppendMPI(gotrax.AppendMPI([]byte{}, fixedGX()), fixedY()))
340+
gx, err := extractGx(AppendMPI(AppendMPI([]byte{}, fixedGX()), fixedY()))
343341
assertDeepEquals(t, err.Error(), "otr: gx corrupt after decryption")
344342
assertDeepEquals(t, gx, fixedGX())
345343
}
@@ -350,7 +348,7 @@ func Test_extractGx_returnsErrorWhenThereIsNotEnoughLengthForTheMPI(t *testing.T
350348
}
351349

352350
func Test_extractGxWithRangeError(t *testing.T) {
353-
gx, err := extractGx(gotrax.AppendMPI([]byte{}, big.NewInt(1)))
351+
gx, err := extractGx(AppendMPI([]byte{}, big.NewInt(1)))
354352
assertDeepEquals(t, gx, big.NewInt(1))
355353
assertDeepEquals(t, err.Error(), "otr: DH value out of range")
356354
}

auth_state_machine.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package otr3
33
import (
44
"bytes"
55
"time"
6-
7-
"github.com/coyim/gotrax"
86
)
97

108
func (c *Conversation) generateNewDHKeyPair() error {
@@ -120,13 +118,13 @@ func (s authStateAwaitingRevealSig) receiveDHCommitMessage(c *Conversation, msg
120118
}
121119

122120
func (s authStateAwaitingDHKey) receiveDHCommitMessage(c *Conversation, msg []byte) (authState, messageWithHeader, error) {
123-
newMsg, _, ok := gotrax.ExtractData(msg)
124-
_, theirHashedGx, ok2 := gotrax.ExtractData(newMsg)
121+
newMsg, _, ok := ExtractData(msg)
122+
_, theirHashedGx, ok2 := ExtractData(newMsg)
125123
if !(ok && ok2) {
126124
return s, nil, errInvalidOTRMessage
127125
}
128-
129-
gxMPI := gotrax.AppendMPI(nil, c.ake.ourPublicValue)
126+
127+
gxMPI := AppendMPI(nil, c.ake.ourPublicValue)
130128
hashedGx := c.version.hash2(gxMPI)
131129
//If yours is the higher hash value:
132130
//Ignore the incoming D-H Commit message, but resend your D-H Commit message.

auth_state_machine_test.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package otr3
33
import (
44
"math/big"
55
"testing"
6-
7-
"github.com/coyim/gotrax"
86
)
97

108
func Test_conversationInitialState(t *testing.T) {
@@ -36,8 +34,8 @@ func Test_receiveDHCommit_AtAuthStateNoneStoresEncryptedGxAndHashedGx(t *testing
3634
c := newConversation(otrV3{}, fixtureRand())
3735

3836
dhCommitMsg := fixtureDHCommitMsgBody()
39-
newMsg, encryptedGx, _ := gotrax.ExtractData(dhCommitMsg)
40-
_, hashedGx, _ := gotrax.ExtractData(newMsg)
37+
newMsg, encryptedGx, _ := ExtractData(dhCommitMsg)
38+
_, hashedGx, _ := ExtractData(newMsg)
4139

4240
nextState, nextMsg, err := authStateNone{}.receiveDHCommitMessage(c, dhCommitMsg)
4341
assertEquals(t, err, nil)
@@ -69,8 +67,8 @@ func Test_receiveDHCommit_AtAuthAwaitingRevealSigiForgetOldEncryptedGxAndHashedG
6967
c.ake.xhashedGx = fixedSize(otrV3{}.hash2Length(), []byte{0x05}) //some hashedGx
7068

7169
newDHCommitMsg := fixtureDHCommitMsgBody()
72-
newMsg, newEncryptedGx, _ := gotrax.ExtractData(newDHCommitMsg)
73-
_, newHashedGx, _ := gotrax.ExtractData(newMsg)
70+
newMsg, newEncryptedGx, _ := ExtractData(newDHCommitMsg)
71+
_, newHashedGx, _ := ExtractData(newMsg)
7472

7573
authStateNone{}.receiveDHCommitMessage(c, fixtureDHCommitMsgBody())
7674

@@ -101,7 +99,7 @@ func Test_receiveDHCommit_AtAwaitingDHKeyIgnoreIncomingMsgAndResendOurDHCommitMs
10199

102100
// force their hashedGx to be lower than ours
103101
msg := fixtureDHCommitMsgBody()
104-
newPoint, _, _ := gotrax.ExtractData(msg)
102+
newPoint, _, _ := ExtractData(msg)
105103
newPoint[4] = 0x00
106104

107105
state, newMsg, err := authStateAwaitingDHKey{}.receiveDHCommitMessage(c, msg)
@@ -121,7 +119,7 @@ func Test_receiveDHCommit_AtAwaitingDHKeyForgetOurGxAndSendDHKeyMsgAndGoToAwaiti
121119

122120
// force their hashedGx to be higher than ours
123121
msg := fixtureDHCommitMsgBody()
124-
newPoint, _, _ := gotrax.ExtractData(msg)
122+
newPoint, _, _ := ExtractData(msg)
125123
newPoint[4] = 0xFF
126124

127125
state, newMsg, err := authStateAwaitingDHKey{}.receiveDHCommitMessage(c, msg)

data.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import (
44
"hash"
55
"math/big"
66
"strconv"
7-
8-
"github.com/coyim/gotrax"
97
)
108

119
func hashMPIs(h hash.Hash, magic byte, mpis ...*big.Int) []byte {
1210
h.Reset()
1311
h.Write([]byte{magic})
1412
for _, mpi := range mpis {
15-
h.Write(gotrax.AppendMPI(nil, mpi))
13+
h.Write(AppendMPI(nil, mpi))
1614
}
1715
return h.Sum(nil)
1816
}

extra_key.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package otr3
22

3-
import "github.com/coyim/gotrax"
4-
53
func (c *Conversation) processExtraSymmetricKeyTLV(t tlv, x dataMessageExtra) (toSend *tlv, err error) {
6-
rest, usage, ok := gotrax.ExtractWord(t.tlvValue[:t.tlvLength])
4+
rest, usage, ok := ExtractWord(t.tlvValue[:t.tlvLength])
75
if ok {
86
c.receivedSymKey(usage, rest, x.key)
97
}
@@ -21,7 +19,7 @@ func (c *Conversation) UseExtraSymmetricKey(usage uint32, usageData []byte) ([]b
2119
t := tlv{
2220
tlvType: tlvTypeExtraSymmetricKey,
2321
tlvLength: 4 + uint16(len(usageData)),
24-
tlvValue: append(gotrax.AppendWord(nil, usage), usageData...),
22+
tlvValue: append(AppendWord(nil, usage), usageData...),
2523
}
2624

2725
toSend, x, err := c.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{t})

0 commit comments

Comments
 (0)