From d82e2718e2a1346b231abda31a102b144ac21090 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 23 Mar 2006 11:54:51 +0000 Subject: Add information and pem strings. Update dependencies. --- crypto/pem/pem_lib.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crypto/pem') 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 +#include #include "cryptlib.h" #include #include @@ -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; + } + -- cgit v1.2.3