Documentation ¶
Index ¶
- Constants
- Variables
- func AEStoEncryptedPEM(raw []byte, pwd []byte) ([]byte, error)
- func AEStoPEM(raw []byte) []byte
- func CBCDecrypt(key, src []byte) ([]byte, error)
- func CBCEncrypt(key, s []byte) ([]byte, error)
- func CBCPKCS7Decrypt(key, src []byte) ([]byte, error)
- func CBCPKCS7Encrypt(key, src []byte) ([]byte, error)
- func CheckCertAgainRoot(x509Cert *x509.Certificate, certPool *x509.CertPool) ([][]*x509.Certificate, error)
- func CheckCertAgainstSKAndRoot(x509Cert *x509.Certificate, privateKey interface{}, certPool *x509.CertPool) error
- func CheckCertPKAgainstSK(x509Cert *x509.Certificate, privateKey interface{}) error
- func Clone(src []byte) []byte
- func DERCertToPEM(der []byte) []byte
- func DERToPrivateKey(der []byte) (interface{}, error)
- func DERToX509Certificate(asn1Data []byte) (*x509.Certificate, error)
- func DecodeBase64(in string) ([]byte, error)
- func DirEmpty(path string) (bool, error)
- func DirExists(path string) (bool, error)
- func DirMissingOrEmpty(path string) (bool, error)
- func ECDSASign(signKey interface{}, msg []byte) ([]byte, error)
- func ECDSASignDirect(signKey interface{}, msg []byte) (*big.Int, *big.Int, error)
- func ECDSAVerify(verKey interface{}, msg, signature []byte) (bool, error)
- func EncodeBase64(in []byte) string
- func ErrToString(err error) string
- func FileMissing(path string, name string) (bool, error)
- func FilePathMissing(path string) (bool, error)
- func GenAESKey() ([]byte, error)
- func GetCriticalExtension(cert *x509.Certificate, oid asn1.ObjectIdentifier) ([]byte, error)
- func GetRandomBytes(len int) ([]byte, error)
- func HMAC(key, x []byte) []byte
- func HMACTruncated(key, x []byte, truncation int) []byte
- func Hash(msg []byte) []byte
- func IntArrayEquals(a []int, b []int) bool
- func IsTCPPortOpen(laddr string) error
- func NewECDSAKey() (*ecdsa.PrivateKey, error)
- func NewHash() hash.Hash
- func NewSelfSignedCert() ([]byte, interface{}, error)
- func PEMtoAES(raw []byte, pwd []byte) ([]byte, error)
- func PEMtoCertificate(raw []byte) (*x509.Certificate, error)
- func PEMtoCertificateAndDER(raw []byte) (*x509.Certificate, []byte, error)
- func PEMtoDER(raw []byte) ([]byte, error)
- func PEMtoPrivateKey(raw []byte, pwd []byte) (interface{}, error)
- func PKCS7Padding(src []byte) []byte
- func PKCS7UnPadding(src []byte) ([]byte, error)
- func PrivateKeyToDER(privateKey *ecdsa.PrivateKey) ([]byte, error)
- func PrivateKeyToEncryptedPEM(privateKey interface{}, pwd []byte) ([]byte, error)
- func PrivateKeyToPEM(privateKey interface{}, pwd []byte) ([]byte, error)
- func PublicKeyToPEM(algo string, publicKey interface{}) ([]byte, error)
- func VerifySignCapability(tempSK interface{}, certPK interface{}) error
- type ECDSASignature
- type NodeConfiguration
Constants ¶
const ( // AESKeyLength is the default AES key length AESKeyLength = 32 // NonceSize is the default NonceSize NonceSize = 24 )
Variables ¶
var ( // ErrRegistrationRequired Registration to the Membership Service required. ErrRegistrationRequired = errors.New("Registration to the Membership Service required.") // ErrNotInitialized Initialization required ErrNotInitialized = errors.New("Initialization required.") // ErrAlreadyInitialized Already initialized ErrAlreadyInitialized = errors.New("Already initialized.") // ErrAlreadyRegistered Already registered ErrAlreadyRegistered = errors.New("Already registered.") // ErrTransactionMissingCert Transaction missing certificate or signature ErrTransactionMissingCert = errors.New("Transaction missing certificate or signature.") // ErrInvalidTransactionSignature Invalid Transaction Signature ErrInvalidTransactionSignature = errors.New("Invalid Transaction Signature.") // ErrTransactionCertificate Missing Transaction Certificate ErrTransactionCertificate = errors.New("Missing Transaction Certificate.") // ErrTransactionSignature Missing Transaction Signature ErrTransactionSignature = errors.New("Missing Transaction Signature.") // ErrInvalidSignature Invalid Signature ErrInvalidSignature = errors.New("Invalid Signature.") // ErrInvalidReference Invalid reference ErrInvalidReference = errors.New("Invalid reference.") // ErrInvalidReference Invalid reference ErrNilArgument = errors.New("Nil argument.") // ErrNotImplemented Not implemented ErrNotImplemented = errors.New("Not implemented.") // ErrKeyStoreAlreadyInitialized Keystore already Initilized ErrKeyStoreAlreadyInitialized = errors.New("Keystore already Initilized.") // ErrEncrypt Encryption failed ErrEncrypt = errors.New("Encryption failed.") // ErrDecrypt Decryption failed ErrDecrypt = errors.New("Decryption failed.") // ErrDirrentChaincodeID ChaincodeIDs are different ErrDirrentChaincodeID = errors.New("ChaincodeIDs are different.") // ErrInvalidConfidentialityLevel Invalid confidentiality level ErrInvalidConfidentialityLevel = errors.New("Invalid confidentiality level") )
var (
DefaultCurve = elliptic.P384()
)
var ( // TCertEncTCertIndex oid for TCertIndex TCertEncTCertIndex = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 7} )
Functions ¶
func AEStoEncryptedPEM ¶
AEStoEncryptedPEM encapsulates an AES key in the encrypted PEM format
func CBCDecrypt ¶
CBCDecrypt decrypts using CBC mode
func CBCPKCS7Decrypt ¶
CBCPKCS7Decrypt combines CBC decryption and PKCS7 unpadding
func CBCPKCS7Encrypt ¶
CBCPKCS7Encrypt combines CBC encryption and PKCS7 padding
func CheckCertAgainRoot ¶
func CheckCertAgainRoot(x509Cert *x509.Certificate, certPool *x509.CertPool) ([][]*x509.Certificate, error)
func CheckCertAgainstSKAndRoot ¶
func CheckCertAgainstSKAndRoot(x509Cert *x509.Certificate, privateKey interface{}, certPool *x509.CertPool) error
func CheckCertPKAgainstSK ¶
func CheckCertPKAgainstSK(x509Cert *x509.Certificate, privateKey interface{}) error
func DERToPrivateKey ¶
DERToPrivateKey unmarshals a der to private key
func DERToX509Certificate ¶
func DERToX509Certificate(asn1Data []byte) (*x509.Certificate, error)
DERToX509Certificate converts der to x509
func DirMissingOrEmpty ¶
DirMissingOrEmpty checks is a directory is missin or empty
func ECDSASignDirect ¶
ECDSASignDirect signs
func ECDSAVerify ¶
ECDSAVerify verifies
func ErrToString ¶
func FileMissing ¶
FileMissing checks if a file is missing
func FilePathMissing ¶
FilePathMissing returns true if the path is missing, false otherwise.
func GetCriticalExtension ¶
func GetCriticalExtension(cert *x509.Certificate, oid asn1.ObjectIdentifier) ([]byte, error)
GetCriticalExtension returns a requested critical extension. It also remove it from the list of unhandled critical extensions
func GetRandomBytes ¶
GetRandomBytes returns len random looking bytes
func HMACTruncated ¶
HMACTruncated hmacs x using key key and truncate to truncation
func IntArrayEquals ¶
IntArrayEquals checks if the arrays of ints are the same
func IsTCPPortOpen ¶
IsTCPPortOpen checks the tcp port is open
func NewECDSAKey ¶
func NewECDSAKey() (*ecdsa.PrivateKey, error)
NewECDSAKey generates a new ECDSA Key
func NewSelfSignedCert ¶
NewSelfSignedCert create a self signed certificate
func PEMtoCertificate ¶
func PEMtoCertificate(raw []byte) (*x509.Certificate, error)
PEMtoCertificate converts pem to x509
func PEMtoCertificateAndDER ¶
func PEMtoCertificateAndDER(raw []byte) (*x509.Certificate, []byte, error)
PEMtoCertificateAndDER converts pem to x509 and der
func PEMtoPrivateKey ¶
PEMtoPrivateKey unmarshals a pem to private key
func PKCS7Padding ¶
PKCS7Padding pads as prescribed by the PKCS7 standard
func PKCS7UnPadding ¶
PKCS7UnPadding unpads as prescribed by the PKCS7 standard
func PrivateKeyToDER ¶
func PrivateKeyToDER(privateKey *ecdsa.PrivateKey) ([]byte, error)
PrivateKeyToDER marshals a private key to der
func PrivateKeyToEncryptedPEM ¶
PrivateKeyToEncryptedPEM converts a private key to an encrypted PEM
func PrivateKeyToPEM ¶
PrivateKeyToPEM converts a private key to PEM
func PublicKeyToPEM ¶
PublicKeyToPEM marshals a public key to the pem forma
func VerifySignCapability ¶
func VerifySignCapability(tempSK interface{}, certPK interface{}) error
VerifySignCapability tests signing capabilities
Types ¶
type ECDSASignature ¶
ECDSASignature represents an ECDSA signature
type NodeConfiguration ¶
NodeConfiguration used for testing
func (*NodeConfiguration) GetEnrollmentID ¶
func (conf *NodeConfiguration) GetEnrollmentID() string
GetEnrollmentID returns the enrollment ID
func (*NodeConfiguration) GetEnrollmentPWD ¶
func (conf *NodeConfiguration) GetEnrollmentPWD() string
GetEnrollmentPWD returns the enrollment PWD