Changes by: antona
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11913/ntfsprogs
Modified Files:
ntfsdecrypt.c
Log Message:
Add some debugging to ntfsdecrypt.c to allow printing of the private
key after it is decrypted (this is ifdeffed out by default). (Anton)
Index: ntfsdecrypt.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsdecrypt.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -p -r1.21 -r1.22
--- ntfsdecrypt.c 15 Oct 2005 22:30:20 -0000 1.21
+++ ntfsdecrypt.c 25 Oct 2005 22:12:25 -0000 1.22
@@ -394,18 +394,8 @@ static ntfs_rsa_private_key ntfs_rsa_pri
}
/* Release the no longer needed datum values. */
for (j = 0; j < 6; j++) {
- /*
- * FIXME: _gnutls_free_datum() is not exported from libgnutls
- * so we do it by hand... )-: Let us just hope the
- * gnutls_datum_t structure does not change across versions of
- * the gnutls library.
- */
-#if 0
- _gnutls_free_datum(&rd[j]);
-#else
if (rd[j].data && rd[j].size)
gnutls_free(rd[j].data);
-#endif
}
/*
* Build the gcrypt private key, note libgcrypt uses p and q inversed
@@ -528,6 +518,28 @@ check_again:
gnutls_strerror(err));
goto key_out;
}
+#if 0
+ /*
+ * Export the key again, but unencrypted, and output it
+ * to stderr. Note the output has an RSA header so to
+ * compare to openssl pkcs12 -nodes -in myfile.pfx
+ * output need to ignore the part of the key between
+ * the first "MII..." up to the second "MII...". The
+ * actual RSA private key begins at the second "MII..."
+ * and in my testing at least was identical to openssl
+ * output and was also identical both on big and little
+ * endian so gnutls should be endianness safe.
+ */
+ char *buf = malloc(8192);
+ size_t bufsize = 8192;
+ err = gnutls_x509_privkey_export_pkcs8(pkey, GNUTLS_X509_FMT_PEM, "", GNUTLS_PKCS_PLAIN, buf, &bufsize);
+ if (err) {
+ fprintf(stderr, "eek1\n");
+ exit(1);
+ }
+ fprintf(stderr, "%s\n", buf);
+ free(buf);
+#endif
/* Convert the private key to our internal format. */
rsa_key = ntfs_rsa_private_key_import_from_gnutls(pkey);
goto key_out;
|