mirror of
https://github.com/gregtwallace/apc-p15-tool.git
synced 2025-07-13 18:53:23 +00:00
key: finish key encoding and start cert
This commit is contained in:
parent
85462c93b1
commit
1f6dad4907
14 changed files with 592 additions and 115 deletions
pkg/pkcs15
|
@ -3,6 +3,7 @@ package pkcs15
|
|||
import (
|
||||
"apc-p15-tool/pkg/tools/asn1obj"
|
||||
"crypto/sha1"
|
||||
"encoding/asn1"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
|
@ -13,7 +14,7 @@ func (p15 *pkcs15KeyCert) keyId() []byte {
|
|||
asn1obj.Sequence([][]byte{
|
||||
// Key is RSA
|
||||
asn1obj.ObjectIdentifier(asn1obj.OIDrsaEncryptionPKCS1),
|
||||
asn1obj.Null(),
|
||||
asn1.NullBytes,
|
||||
}),
|
||||
// BIT STRING of rsa key public key
|
||||
asn1obj.BitString(
|
||||
|
@ -33,3 +34,19 @@ func (p15 *pkcs15KeyCert) keyId() []byte {
|
|||
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
||||
// keyIdInt2 returns the sequence for keyId with INT val of 2
|
||||
// For APC, this appears to be the same value is the base keyId
|
||||
// but this isn't compliant with the spec which actually seems
|
||||
// to call for SKID (skid octet value copied directly out of the
|
||||
// certificate's x509 extension)
|
||||
func (p15 *pkcs15KeyCert) keyIdInt2() []byte {
|
||||
// Create Object
|
||||
obj := asn1obj.Sequence([][]byte{
|
||||
asn1obj.Integer(big.NewInt(2)),
|
||||
// Note: This is for APC, doesn't seem compliant with spec though
|
||||
asn1obj.OctetString(p15.keyId()),
|
||||
})
|
||||
|
||||
return obj
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue