Added support for RSASSA-PSS and RSAES-OAEP.

This commit is contained in:
InfiniteLoopSpace
2018-12-21 14:43:59 +01:00
parent 5f34d82562
commit 3f58f9a4b2
10 changed files with 510 additions and 181 deletions

View File

@ -25,8 +25,15 @@ func Encrypt(in []byte, cert *x509.Certificate, opts ...string) (der []byte, err
pem.Encode(tmpKey, &pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw})
param := []string{SMIME, "-encrypt", "-aes128"}
param = append(param, opts...)
param = append(param, tmpKey.Name())
if SMIME == "smime" {
// For smime arguments can not be passed after the keyfile
param = append(param, opts...)
param = append(param, tmpKey.Name())
} else {
// Keyots have to be passed after the key
param = append(param, "-recip", tmpKey.Name())
param = append(param, opts...)
}
der, err = openssl(in, param...)
return
@ -76,9 +83,8 @@ func SignDetached(in []byte, cert *x509.Certificate, key crypto.PrivateKey, inte
pem.Encode(tmpInterm, &pem.Block{Type: "CERTIFICATE", Bytes: i.Raw})
}
param := []string{SMIME, "-sign", "-nodetach"}
param := []string{SMIME, "-sign", "-nodetach", "-signer", tmpCert.Name(), "-inkey", tmpKey.Name(), "-certfile", tmpInterm.Name()}
param = append(param, opts...)
param = append(param, []string{"-signer", tmpCert.Name(), "-inkey", tmpKey.Name(), "-certfile", tmpInterm.Name()}...)
plain, err = openssl(in, param...)
return