EVP keys have a variable encryption envelope, which is used by openssh, so
adding EVP key support allows create_tpm_key to read ssh v2 keys

Signed-off-by: James Bottomley <[email protected]>
---
 create_tpm_key.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/create_tpm_key.c b/create_tpm_key.c
index 1c1e556..9cef1fe 100644
--- a/create_tpm_key.c
+++ b/create_tpm_key.c
@@ -95,6 +95,7 @@ RSA *
 openssl_read_key(char *filename)
 {
         BIO *b = NULL;
+       EVP_PKEY *pkey;
         RSA *rsa = NULL;
 
         b = BIO_new_file(filename, "r");
@@ -103,12 +104,14 @@ openssl_read_key(char *filename)
                 return NULL;
         }
 
-        if ((rsa = PEM_read_bio_RSAPrivateKey(b, NULL, 0, NULL)) == NULL) {
+        if ((pkey = PEM_read_bio_PrivateKey(b, NULL, PEM_def_callback, NULL)) 
== NULL) {
                 fprintf(stderr, "Reading key %s from disk failed.\n", 
filename);
                 openssl_print_errors();
         }
        BIO_free(b);
 
+       rsa = EVP_PKEY_get1_RSA(pkey);
+
         return rsa;
 }
 
@@ -406,6 +409,9 @@ int main(int argc, char **argv)
                unsigned int size_n, size_p;
                BYTE *pubSRK;
 
+               /* may be needed to decrypt the key */
+               OpenSSL_add_all_ciphers();
+
                /*Set migration policy needed to wrap the key*/
                if ((result = Tspi_Context_CreateObject(hContext,
                                                TSS_OBJECT_TYPE_POLICY,
-- 
2.6.6


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to