+
+/*
+ * See whether an RSA key is encrypted. Return its comment field as
+ * well.
+ */
+int rsakey_encrypted(char *filename, char **comment) {
+ FILE *fp;
+ unsigned char buf[64];
+
+ fp = fopen(filename, "rb");
+ if (!fp)
+ return 0; /* doesn't even exist */
+
+ /*
+ * Read the first line of the file and see if it's a v1 private
+ * key file.
+ */
+ if (fgets(buf, sizeof(buf), fp) &&
+ !strcmp(buf, rsa_signature)) {
+ return loadrsakey_main(fp, NULL, comment, NULL);
+ }
+ return 0; /* wasn't the right kind of file */
+}