mirror of
https://github.com/gregtwallace/apc-p15-tool.git
synced 2025-07-09 01:06:32 +00:00
app: restructure and start building p15 output
This commit is contained in:
parent
6610c92058
commit
e2e4f2037c
24 changed files with 622 additions and 168 deletions
pkg/pkcs15
35
pkg/pkcs15/keyid.go
Normal file
35
pkg/pkcs15/keyid.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package pkcs15
|
||||
|
||||
import (
|
||||
"apc-p15-tool/pkg/tools/asn1obj"
|
||||
"crypto/sha1"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// keyId returns the keyId for the overall key object
|
||||
func (p15 *pkcs15KeyCert) keyId() []byte {
|
||||
// Create Object to hash
|
||||
hashObj := asn1obj.Sequence([][]byte{
|
||||
asn1obj.Sequence([][]byte{
|
||||
// Key is RSA
|
||||
asn1obj.ObjectIdentifier(asn1obj.OIDrsaEncryptionPKCS1),
|
||||
asn1obj.Null(),
|
||||
}),
|
||||
// BIT STRING of rsa key public key
|
||||
asn1obj.BitString(
|
||||
asn1obj.Sequence([][]byte{
|
||||
asn1obj.Integer(p15.key.N),
|
||||
asn1obj.Integer((big.NewInt(int64(p15.key.E)))),
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
// SHA-1 Hash
|
||||
hasher := sha1.New()
|
||||
_, err := hasher.Write(hashObj)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return hasher.Sum(nil)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue