-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
67 lines (55 loc) · 1.94 KB
/
interfaces.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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package entities
// Entity is the basic interface for all crypto entities
// that are used by the library to obtain cc-level encryption
type Entity interface {
// ID returns an identifier for the entity;
// the identifier can be set arbitrarily by
// the entity's constructor in a manner that
// is relevant for its usage at the cc-level
ID() string
// Equals compares this entity with the supplied
// one and returns a boolean that is true if the
// two entities are identical. This includes any
// and all key material that the entity uses
Equals(Entity) bool
// Public returns the public version of this entity
// in case asymmetric cryptography is used. If not,
// Public returns itself
Public() (Entity, error)
}
// Signer is an interface that provides basic sign/verify capabilities
type Signer interface {
// Sign returns a signature of the supplied message (or an error)
Sign(msg []byte) (signature []byte, err error)
// Verify checks whether the supplied signature
// over the supplied message is valid according to this interface
Verify(signature, msg []byte) (valid bool, err error)
}
// Encrypter is an interface that provides basic encrypt/decrypt capabilities
type Encrypter interface {
// Encrypt returns the ciphertext for the supplied plaintext message
Encrypt(plaintext []byte) (ciphertext []byte, err error)
// Decrypt returns the plaintext for the supplied ciphertext message
Decrypt(ciphertext []byte) (plaintext []byte, err error)
}
// Encrypter entity is an entity which is capable of performing encryption
type EncrypterEntity interface {
Entity
Encrypter
}
// SignerEntity is an entity which is capable of signing
type SignerEntity interface {
Entity
Signer
}
// EncrypterSignerEntity is an entity which is capable of performing
// encryption and of generating signatures
type EncrypterSignerEntity interface {
Entity
Encrypter
Signer
}