-
Notifications
You must be signed in to change notification settings - Fork 5
/
cipher.go
68 lines (54 loc) · 1.38 KB
/
cipher.go
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
package foundation
import "C"
/*
* Provide interface for symmetric ciphers.
*/
type Cipher interface {
context
/*
* Setup IV or nonce.
*/
SetNonce (nonce []byte)
/*
* Set cipher encryption / decryption key.
*/
SetKey (key []byte)
/*
* Start sequential encryption.
*/
StartEncryption ()
/*
* Start sequential decryption.
*/
StartDecryption ()
/*
* Process encryption or decryption of the given data chunk.
*/
Update (data []byte) []byte
/*
* Return buffer length required to hold an output of the methods
* "update" or "finish" in an current mode.
* Pass zero length to define buffer length of the method "finish".
*/
OutLen (dataLen uint) uint
/*
* Return buffer length required to hold an output of the methods
* "update" or "finish" in an encryption mode.
* Pass zero length to define buffer length of the method "finish".
*/
EncryptedOutLen (dataLen uint) uint
/*
* Return buffer length required to hold an output of the methods
* "update" or "finish" in an decryption mode.
* Pass zero length to define buffer length of the method "finish".
*/
DecryptedOutLen (dataLen uint) uint
/*
* Accomplish encryption or decryption process.
*/
Finish () ([]byte, error)
/*
* Release underlying C context.
*/
Delete ()
}