mirror of
https://github.com/gregtwallace/apc-p15-tool.git
synced 2025-07-09 17:16:34 +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
36
pkg/pkcs15/pem_to_p15.go
Normal file
36
pkg/pkcs15/pem_to_p15.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package pkcs15
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
)
|
||||
|
||||
// pkcs15KeyCert holds the data for a key and certificate pair; it provides
|
||||
// various methods to transform pkcs15 data
|
||||
type pkcs15KeyCert struct {
|
||||
key *rsa.PrivateKey
|
||||
cert *x509.Certificate
|
||||
}
|
||||
|
||||
// ParsePEMToPKCS15 parses the provide pem files to a pkcs15 struct; it also does some
|
||||
// basic sanity check; if any of this fails, an error is returned
|
||||
func ParsePEMToPKCS15(keyPem, certPem []byte) (*pkcs15KeyCert, error) {
|
||||
// decode / check key
|
||||
key, err := pemKeyDecode(keyPem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// decode / check cert
|
||||
cert, err := pemCertDecode(certPem, keyPem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p15 := &pkcs15KeyCert{
|
||||
key: key,
|
||||
cert: cert,
|
||||
}
|
||||
|
||||
return p15, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue