Repository navigation
Expand file tree
/
Copy pathtranscript.go
More file actions
77 lines (67 loc) · 1.87 KB
/
Copy pathtranscript.go
File metadata and controls
77 lines (67 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package cpace
import "crypto/sha512"
type irTranscript struct {
transcript []byte
ya []byte
ada []byte
yb []byte
adb []byte
}
func newIRTranscript(ya, ada, yb, adb []byte) irTranscript {
ya = clone(ya)
ada = clone(ada)
yb = clone(yb)
adb = clone(adb)
transcript := lvCat(ya, ada)
transcript = append(transcript, lvCat(yb, adb)...)
return irTranscript{
transcript: transcript,
ya: ya,
ada: ada,
yb: yb,
adb: adb,
}
}
func (t *irTranscript) transcriptID() []byte {
return transcriptID(t.transcript)
}
func (t *irTranscript) deriveISK(sid, k []byte) []byte {
return deriveISK(sid, k, t.transcript)
}
// initiatorAD returns a copy of the initiator's associated data bound into the
// transcript. The responder uses it to populate the confirmed Session's peer
// associated data without retaining a decomposed field of its own.
func (t *irTranscript) initiatorAD() []byte {
return clone(t.ada)
}
// clear zeroes then nils the transcript's public byte fields. The responder
// calls it from responderCore.clear so the stored transcript is wiped
// alongside the ISK as hygiene (ADR-0001); the transcript holds no secret of
// its own. Safe to call more than once and on a nil receiver.
func (t *irTranscript) clear() {
if t == nil {
return
}
clearBytes(t.transcript)
clearBytes(t.ya)
clearBytes(t.ada)
clearBytes(t.yb)
clearBytes(t.adb)
t.transcript = nil
t.ya = nil
t.ada = nil
t.yb = nil
t.adb = nil
}
func (t *irTranscript) initiatorConfirmationTag(isk, sid []byte) []byte {
return confirmationTag(isk, sid, t.ya, t.ada)
}
func (t *irTranscript) responderConfirmationTag(isk, sid []byte) []byte {
return confirmationTag(isk, sid, t.yb, t.adb)
}
func transcriptID(transcript []byte) []byte {
h := sha512.New()
_, _ = h.Write([]byte("CPaceSidOutput"))
_, _ = h.Write(transcript)
return h.Sum(nil)
}