diff options
author | msvensson@neptunus.(none) <> | 2006-09-25 16:40:29 +0200 |
---|---|---|
committer | msvensson@neptunus.(none) <> | 2006-09-25 16:40:29 +0200 |
commit | 64a64d0fbf29443cd0229bba0d7b2dfdf9624306 (patch) | |
tree | 1f8d7ab8dca1697f70a230f4fdcbd108cdf21ccf /extra/yassl/src/crypto_wrapper.cpp | |
parent | d8e27606e1716d674ce03588cb8e763fbc260b62 (diff) | |
download | mariadb-git-64a64d0fbf29443cd0229bba0d7b2dfdf9624306.tar.gz |
Import yaSSL version 1.4.0
Diffstat (limited to 'extra/yassl/src/crypto_wrapper.cpp')
-rw-r--r-- | extra/yassl/src/crypto_wrapper.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index 799106ec7c0..7344a70b367 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -908,7 +908,7 @@ void DiffieHellman::get_parms(byte* bp, byte* bg, byte* bpub) const // convert PEM file to DER x509 type -x509* PemToDer(FILE* file, CertType type) +x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info) { using namespace TaoCrypt; @@ -935,6 +935,37 @@ x509* PemToDer(FILE* file, CertType type) break; } + // remove encrypted header if there + if (fgets(line, sizeof(line), file)) { + char encHeader[] = "Proc-Type"; + if (strncmp(encHeader, line, strlen(encHeader)) == 0 && + fgets(line,sizeof(line), file)) { + + char* start = strstr(line, "DES"); + char* finish = strstr(line, ","); + if (!start) + start = strstr(line, "AES"); + + if (!info) return 0; + + if ( start && finish && (start < finish)) { + memcpy(info->name, start, finish - start); + info->name[finish - start] = 0; + memcpy(info->iv, finish + 1, sizeof(info->iv)); + + char* newline = strstr(line, "\r"); + if (!newline) newline = strstr(line, "\n"); + if (newline && (newline > finish)) { + info->ivSz = newline - (finish + 1); + info->set = true; + } + } + fgets(line,sizeof(line), file); // get blank line + begin = ftell(file); + } + + } + while(fgets(line, sizeof(line), file)) if (strncmp(footer, line, strlen(footer)) == 0) { foundEnd = true; @@ -956,7 +987,7 @@ x509* PemToDer(FILE* file, CertType type) Base64Decoder b64Dec(der); uint sz = der.size(); - mySTL::auto_ptr<x509> x(NEW_YS x509(sz), ysDelete); + mySTL::auto_ptr<x509> x(NEW_YS x509(sz)); memcpy(x->use_buffer(), der.get_buffer(), sz); return x.release(); |