Documentation ¶
Index ¶
- Constants
- Variables
- 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 ConvertDERToPEM(der []byte, datatype string) []byte
- func CreateRootPreKey() string
- func GenNumber(numlen *big.Int) (*big.Int, error)
- func GenerateBytesUUID() ([]byte, error)
- func GenerateIntUUID() (*big.Int, error)
- func GetCertificate(certificate []byte) (*x509.Certificate, error)
- func GetCertitificateSerialNumber(certificatebyte []byte) (*big.Int, error)
- func GetEnrollmentIDFromCert(ecert *x509.Certificate) string
- func GetPrivateKey(buf []byte) (interface{}, error)
- func LoadCert(path string) (*x509.Certificate, error)
- func LoadKey(path string) (interface{}, error)
- func PKCS7Padding(src []byte) []byte
- func PKCS7UnPadding(src []byte) ([]byte, error)
- func ParsePrivateKey(der []byte) (interface{}, error)
- func ValidateCert(cert *x509.Certificate) bool
- type GetTCertBatchRequest
- type KeyTree
- type Mgr
Constants ¶
const (
// AESKeyLength is the default AES key length
AESKeyLength = 32
)
Variables ¶
var ( // TCertEncTCertIndex is the ASN1 object identifier of the TCert index. TCertEncTCertIndex = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 7} // TCertEncEnrollmentID is the ASN1 object identifier of the enrollment id. TCertEncEnrollmentID = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 8} // TCertAttributesHeaders is the ASN1 object identifier of attributes header. TCertAttributesHeaders = asn1.ObjectIdentifier{1, 2, 3, 4, 5, 6, 9} // Padding for encryption. Padding = []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} )
var (
//RootPreKeySize is the default value of root key
RootPreKeySize = 48
)
Functions ¶
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 ConvertDERToPEM ¶
ConvertDERToPEM returns data from DER to PEM format DERData is DER
func GenerateBytesUUID ¶
GenerateBytesUUID returns a UUID based on RFC 4122 returning the generated bytes
func GenerateIntUUID ¶
GenerateIntUUID returns a UUID based on RFC 4122 returning a big.Int
func GetCertificate ¶
func GetCertificate(certificate []byte) (*x509.Certificate, error)
GetCertificate returns interface containing *rsa.PublicKey or ecdsa.PublicKey
func GetCertitificateSerialNumber ¶
GetCertitificateSerialNumber returns serial number for Certificate byte return -1 , if there is problem with the cert
func GetEnrollmentIDFromCert ¶
func GetEnrollmentIDFromCert(ecert *x509.Certificate) string
GetEnrollmentIDFromCert retrieves Enrollment Id from certificate
func GetPrivateKey ¶
GetPrivateKey returns ecdsa.PrivateKey or rsa.privateKey object for the private Key Bytes
func LoadCert ¶
func LoadCert(path string) (*x509.Certificate, error)
LoadCert loads a certificate from a file
func PKCS7Padding ¶
PKCS7Padding pads as prescribed by the PKCS7 standard
func PKCS7UnPadding ¶
PKCS7UnPadding unpads as prescribed by the PKCS7 standard
func ParsePrivateKey ¶
ParsePrivateKey parses private key
func ValidateCert ¶
func ValidateCert(cert *x509.Certificate) bool
ValidateCert checks for expiry in the certificate cert Does not check for revocation
Types ¶
type GetTCertBatchRequest ¶
type GetTCertBatchRequest struct { api.GetTCertBatchRequest Attrs []api.Attribute }
GetTCertBatchRequest defines input to the GetBatch API
type KeyTree ¶
type KeyTree struct {
// contains filtered or unexported fields
}
KeyTree is a tree of derived keys
func NewKeyTree ¶
NewKeyTree is the constructor for a key tree
type Mgr ¶
type Mgr struct { // CAKey is used for signing a certificate request CAKey interface{} // CACert is used for extracting CA data to associate with issued certificates CACert *x509.Certificate // ValidityPeriod is the duration that the issued certificate will be valid // unless the user requests a shorter validity period. // The default value is 1 year. ValidityPeriod time.Duration // MaxAllowedBatchSize is the maximum number of TCerts which can be requested at a time. // The default value is 1000. MaxAllowedBatchSize int }
Mgr is the manager for the TCert library
func LoadMgr ¶
LoadMgr is the constructor for a TCert manager given key and certificate file names @parameter caKeyFile is the file name for the CA's key @parameter caCertFile is the file name for the CA's cert
func NewMgr ¶
func NewMgr(caKey interface{}, caCert *x509.Certificate) (*Mgr, error)
NewMgr is the constructor for a TCert manager given a key and an x509 certificate @parameter caKey is used for signing a certificate request @parameter caCert is used for extracting CA data to associate with issued certificates
func (*Mgr) GetBatch ¶
func (tm *Mgr) GetBatch(req *GetTCertBatchRequest, ecert *x509.Certificate) (*api.GetTCertBatchResponse, error)
GetBatch gets a batch of TCerts @parameter req Is the TCert batch request @parameter ecert Is the enrollment certificate of the caller