github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/controller/pkg/secrets/null.go (about) 1 package secrets 2 3 import ( 4 "time" 5 6 jwt "github.com/dgrijalva/jwt-go" 7 ) 8 9 // This is a NULL secrets implementation only for performance testing 10 // ATTENTION *** ONLY FOR TESTING 11 // DO NOT USE FOR ANY REAL CODE 12 13 // NullPKI holds all PKI information 14 type NullPKI struct { 15 PrivateKeyPEM []byte 16 PublicKeyPEM []byte 17 AuthorityPEM []byte 18 } 19 20 // NewNullPKI creates new secrets for PKI implementation based on compact encoding 21 func NewNullPKI(keyPEM, certPEM, caPEM []byte) (*NullPKI, error) { 22 23 p := &NullPKI{} 24 return p, nil 25 } 26 27 // Type implements the interface Secrets 28 func (p *NullPKI) Type() PrivateSecretsType { 29 return PKINull 30 } 31 32 // EncodingKey returns the private key 33 func (p *NullPKI) EncodingKey() interface{} { 34 return jwt.UnsafeAllowNoneSignatureType 35 } 36 37 // PublicKey returns nil in this case 38 func (p *NullPKI) PublicKey() interface{} { 39 return nil 40 } 41 42 //KeyAndClaims returns both the key and any attributes associated with the public key. 43 func (p *NullPKI) KeyAndClaims(pkey []byte) (interface{}, []string, time.Time, error) { 44 return jwt.UnsafeAllowNoneSignatureType, []string{}, time.Now(), nil 45 } 46 47 // TransmittedKey returns the PEM of the public key in the case of PKI 48 // if there is no certificate cache configured 49 func (p *NullPKI) TransmittedKey() []byte { 50 return []byte("none") 51 } 52 53 // AckSize returns the default size of an ACK packet 54 func (p *NullPKI) AckSize() uint32 { 55 return uint32(235) 56 } 57 58 // PublicSecrets returns the secrets that are marshallable over the RPC interface. 59 func (p *NullPKI) PublicSecrets() PublicSecrets { 60 return &NullPublicSecrets{ 61 Type: PKINull, 62 } 63 } 64 65 // NullPublicSecrets includes all the secrets that can be transmitted over 66 // the RPC interface. 67 type NullPublicSecrets struct { 68 Type PrivateSecretsType 69 } 70 71 // SecretsType returns the type of secrets. 72 func (p *NullPublicSecrets) SecretsType() PrivateSecretsType { 73 return p.Type 74 } 75 76 // CertAuthority returns the cert authority - N/A to PSK 77 func (p *NullPublicSecrets) CertAuthority() []byte { 78 return []byte{} 79 }