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 DERToX509Certificate(asn1Data []byte) (*x509.Certificate, error)
- func ECDSASign(signKey interface{}, msg []byte) ([]byte, error)
- func GenAESKey() ([]byte, error)
- func GetCriticalExtension(cert *x509.Certificate, oid asn1.ObjectIdentifier) ([]byte, error)
- func GetDefaultCurve() elliptic.Curve
- func GetDefaultHash() func() hash.Hash
- func GetHashAlgorithm() string
- func GetRandomBytes(len int) ([]byte, error)
- func GetRandomNonce() ([]byte, error)
- func HMAC(key, x []byte) []byte
- func HMACAESTruncated(key, x []byte) []byte
- func HMACTruncated(key, x []byte, truncation int) []byte
- func Hash(msg []byte) []byte
- func InitSecurityLevel(algorithm string, level int) (err error)
- func NewECDSAKey() (*ecdsa.PrivateKey, error)
- func NewHash() hash.Hash
- func NewSelfSignedCert() ([]byte, interface{}, error)
- func PEMtoAES(raw []byte, pwd []byte) ([]byte, error)
- func PKCS7Padding(src []byte) []byte
- func PKCS7UnPadding(src []byte) ([]byte, error)
- func SetSecurityLevel(algorithm string, level int) (err error)
- type ECDSASignature
Constants ¶
const ( // AESKeyLength is the default AES key length AESKeyLength = 32 // NonceSize is the default NonceSize NonceSize = 24 )
Variables ¶
var ( // TCertEncTCertIndex oid for TCertIndex TCertEncTCertIndex = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 7} // TCertEncEnrollmentID is the ASN1 object identifier of the TCert index. TCertEncEnrollmentID = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 8} // TCertEncAttributesBase is the base ASN1 object identifier for attributes. // When generating an extension to include the attribute an index will be // appended to this Object Identifier. TCertEncAttributesBase = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6} // TCertAttributesHeaders is the ASN1 object identifier of attributes header. TCertAttributesHeaders = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 9} )
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 DERToX509Certificate ¶
func DERToX509Certificate(asn1Data []byte) (*x509.Certificate, error)
DERToX509Certificate converts der to x509
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 GetDefaultCurve ¶
GetDefaultCurve returns the default elliptic curve used by the crypto layer
func GetDefaultHash ¶
GetDefaultHash returns the default hash function used by the crypto layer
func GetHashAlgorithm ¶
func GetHashAlgorithm() string
GetHashAlgorithm return the default hash algorithm
func GetRandomBytes ¶
GetRandomBytes returns len random looking bytes
func GetRandomNonce ¶
GetRandomNonce returns a random byte array of length NonceSize
func HMACAESTruncated ¶
HMACAESTruncated hmacs x using key key and truncate to AESKeyLength
func HMACTruncated ¶
HMACTruncated hmacs x using key key and truncate to truncation
func InitSecurityLevel ¶
InitSecurityLevel initialize the crypto layer at the given security level
func NewECDSAKey ¶
func NewECDSAKey() (*ecdsa.PrivateKey, error)
NewECDSAKey generates a new ECDSA Key
func NewSelfSignedCert ¶
NewSelfSignedCert create a self signed certificate
func PKCS7Padding ¶
PKCS7Padding pads as prescribed by the PKCS7 standard
func PKCS7UnPadding ¶
PKCS7UnPadding unpads as prescribed by the PKCS7 standard
func SetSecurityLevel ¶
SetSecurityLevel sets the security configuration with the hash length and the algorithm
Types ¶
type ECDSASignature ¶
ECDSASignature represents an ECDSA signature