summaryrefslogtreecommitdiffstats
path: root/crypto/pem
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2006-03-23 11:54:51 +0000
committerDr. Stephen Henson <steve@openssl.org>2006-03-23 11:54:51 +0000
commitd82e2718e2a1346b231abda31a102b144ac21090 (patch)
tree7ed221e66f158732f34c4b024cfffd2043d83926 /crypto/pem
parent18e377b4ffa6d15572d7283f1eb1743ce5875804 (diff)
Add information and pem strings. Update dependencies.
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pem_lib.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 7cfc2f3e0a..beb40d7f32 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -57,6 +57,7 @@
*/
#include <stdio.h>
+#include <ctype.h>
#include "cryptlib.h"
#include <openssl/buffer.h>
#include <openssl/objects.h>
@@ -776,3 +777,24 @@ err:
BUF_MEM_free(dataB);
return(0);
}
+
+/* Check pem string and return prefix length.
+ * If for example the pem_str == "RSA PRIVATE KEY" and suffix = "PRIVATE KEY"
+ * the return value is 3 for the string "RSA".
+ */
+
+int pem_check_suffix(char *pem_str, char *suffix)
+ {
+ int pem_len = strlen(pem_str);
+ int suffix_len = strlen(suffix);
+ char *p;
+ if (suffix_len + 1 >= pem_len)
+ return 0;
+ if (strcmp(pem_str - suffix_len, suffix))
+ return 0;
+ p = pem_str - suffix_len - 1;
+ if (*p != ' ')
+ return 0;
+ return p - pem_str;
+ }
+