apc-p15-tool/pkg/pkcs15/private_key.go
2024-01-27 11:35:35 -05:00

24 lines
630 B
Go

package pkcs15
import "apc-p15-tool/pkg/tools/asn1obj"
// privateKeyObject returns the ASN.1 representation of a private key
func (p15 *pkcs15KeyCert) privateKeyObject() []byte {
// ensure all expected vals are available
p15.key.Precompute()
pkey := asn1obj.Sequence([][]byte{
// P
asn1obj.IntegerExplicitValue(3, p15.key.Primes[0]),
// Q
asn1obj.IntegerExplicitValue(4, p15.key.Primes[1]),
// Dp
asn1obj.IntegerExplicitValue(5, p15.key.Precomputed.Dp),
// Dq
asn1obj.IntegerExplicitValue(6, p15.key.Precomputed.Dq),
// Qinv
asn1obj.IntegerExplicitValue(7, p15.key.Precomputed.Qinv),
})
return pkey
}