-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.txt
More file actions
50 lines (38 loc) · 2.8 KB
/
Copy pathREADME.txt
File metadata and controls
50 lines (38 loc) · 2.8 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
PACKAGE DOCUMENTATION
package keywrap
import "keywrap"
Package keywrap provides a set of algorithms to wrap/unwrap keywrap with
an encryption key.
Currently, the following algorithms are implemented:
- RFC3394: AES Key Wrap Algorithm
Example:
var wrapper = rfc3394.NewWrapper()
kek, err := hex.DecodeString("000102030405060708090A0B0C0D0E0F")
wrappedKey, err := hex.DecodeString("1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5")
key, err := wrapper.Unwrap(kek, wrappedKey)
if err != nil {
panic(err)
}
var hexKey = strings.ToUpper(hex.EncodeToString(key))
fmt.Println(hexKey)
// Output: 00112233445566778899AABBCCDDEEFF
Example:
var wrapper = rfc3394.NewWrapper()
kek, err := hex.DecodeString("000102030405060708090A0B0C0D0E0F")
key, err := hex.DecodeString("00112233445566778899AABBCCDDEEFF")
wrappedKey, err := wrapper.Wrap(kek, key)
if err != nil {
panic(err)
}
var hexWrappedKey = strings.ToUpper(hex.EncodeToString(wrappedKey))
fmt.Println(hexWrappedKey)
// Output: 1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5
TYPES
type KeyWrapper interface {
Wrap(kek []byte, text []byte) ([]byte, error)
Unwrap(kek []byte, cypheredText []byte) ([]byte, error)
}
KeyWrapper defines the methods to wrap and unwrap a key with an
encryption key whatever is the underlying algorithm
SUBDIRECTORIES
rfc3394