summaryrefslogtreecommitdiff
path: root/extra/yassl/taocrypt
diff options
context:
space:
mode:
authorunknown <msvensson@shellback.(none)>2006-04-26 15:29:52 +0200
committerunknown <msvensson@shellback.(none)>2006-04-26 15:29:52 +0200
commit4449047d0eac62db679300da661b97f11ab574cb (patch)
treeb9b947cdde39d5087b45488c3fb8f5b7e9f8b0d6 /extra/yassl/taocrypt
parent6e8f6d9868342728783f3f2d14e750f9be1a7515 (diff)
downloadmariadb-git-4449047d0eac62db679300da661b97f11ab574cb.tar.gz
Import from upstream yassl
extra/yassl/mySTL/helpers.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/asn.hpp: Import patch yassl.diff extra/yassl/taocrypt/src/asn.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/make.bat: Import patch yassl.diff extra/yassl/taocrypt/src/template_instnt.cpp: Import patch yassl.diff extra/yassl/testsuite/test.hpp: Import patch yassl.diff
Diffstat (limited to 'extra/yassl/taocrypt')
-rw-r--r--extra/yassl/taocrypt/include/asn.hpp19
-rw-r--r--extra/yassl/taocrypt/src/asn.cpp64
-rw-r--r--extra/yassl/taocrypt/src/make.bat2
-rw-r--r--extra/yassl/taocrypt/src/template_instnt.cpp1
4 files changed, 66 insertions, 20 deletions
diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp
index 6a1163fbb1c..7dc349e00db 100644
--- a/extra/yassl/taocrypt/include/asn.hpp
+++ b/extra/yassl/taocrypt/include/asn.hpp
@@ -79,7 +79,13 @@ enum ASNIdFlag
enum DNTags
{
- COMMON_NAME = 0x03
+ COMMON_NAME = 0x03, // CN
+ SUR_NAME = 0x04, // SN
+ COUNTRY_NAME = 0x06, // C
+ LOCALITY_NAME = 0x07, // L
+ STATE_NAME = 0x08, // ST
+ ORG_NAME = 0x0a, // O
+ ORGUNIT_NAME = 0x0b // OU
};
@@ -92,7 +98,8 @@ enum Constants
MAX_SEQ_SZ = 5, // enum(seq|con) + length(4)
MAX_ALGO_SIZE = 9,
MAX_DIGEST_SZ = 25, // SHA + enum(Bit or Octet) + length(4)
- DSA_SIG_SZ = 40
+ DSA_SIG_SZ = 40,
+ NAME_MAX = 512 // max total of all included names
};
@@ -205,14 +212,14 @@ enum { SHA_SIZE = 20 };
// A Signing Authority
class Signer {
PublicKey key_;
- char* name_;
+ char name_[NAME_MAX];
byte hash_[SHA_SIZE];
public:
Signer(const byte* k, word32 kSz, const char* n, const byte* h);
~Signer();
const PublicKey& GetPublicKey() const { return key_; }
- const char* GetCommonName() const { return name_; }
+ const char* GetName() const { return name_; }
const byte* GetHash() const { return hash_; }
private:
@@ -257,8 +264,8 @@ private:
byte subjectHash_[SHA_SIZE]; // hash of all Names
byte issuerHash_[SHA_SIZE]; // hash of all Names
byte* signature_;
- char* issuer_; // CommonName
- char* subject_; // CommonName
+ char issuer_[NAME_MAX]; // Names
+ char subject_[NAME_MAX]; // Names
bool verify_; // Default to yes, but could be off
void ReadHeader();
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index 3efc26ab168..824d1a2056d 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -213,21 +213,17 @@ void PublicKey::AddToEnd(const byte* data, word32 len)
Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h)
- : key_(k, kSz), name_(0)
+ : key_(k, kSz)
{
- if (n) {
int sz = strlen(n);
- name_ = NEW_TC char[sz + 1];
memcpy(name_, n, sz);
name_[sz] = 0;
- }
memcpy(hash_, h, SHA::DIGEST_SIZE);
}
Signer::~Signer()
{
- tcArrayDelete(name_);
}
@@ -424,17 +420,19 @@ void DH_Decoder::Decode(DH& key)
CertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers,
bool noVerify, CertType ct)
: BER_Decoder(s), certBegin_(0), sigIndex_(0), sigLength_(0),
- signature_(0), issuer_(0), subject_(0), verify_(!noVerify)
+ signature_(0), verify_(!noVerify)
{
+ issuer_[0] = 0;
+ subject_[0] = 0;
+
if (decode)
Decode(signers, ct);
+
}
CertDecoder::~CertDecoder()
{
- tcArrayDelete(subject_);
- tcArrayDelete(issuer_);
tcArrayDelete(signature_);
}
@@ -672,8 +670,12 @@ void CertDecoder::GetName(NameType nt)
SHA sha;
word32 length = GetSequence(); // length of all distinguished names
+ assert (length < NAME_MAX);
length += source_.get_index();
+ char* ptr = (nt == ISSUER) ? issuer_ : subject_;
+ word32 idx = 0;
+
while (source_.get_index() < length) {
GetSet();
GetSequence();
@@ -694,13 +696,49 @@ void CertDecoder::GetName(NameType nt)
byte id = source_.next();
b = source_.next(); // strType
word32 strLen = GetLength(source_);
+ bool copy = false;
if (id == COMMON_NAME) {
- char*& ptr = (nt == ISSUER) ? issuer_ : subject_;
- ptr = NEW_TC char[strLen + 1];
- memcpy(ptr, source_.get_current(), strLen);
- ptr[strLen] = 0;
+ memcpy(&ptr[idx], "/CN=", 4);
+ idx += 4;
+ copy = true;
+ }
+ else if (id == SUR_NAME) {
+ memcpy(&ptr[idx], "/SN=", 4);
+ idx += 4;
+ copy = true;
+ }
+ else if (id == COUNTRY_NAME) {
+ memcpy(&ptr[idx], "/C=", 3);
+ idx += 3;
+ copy = true;
+ }
+ else if (id == LOCALITY_NAME) {
+ memcpy(&ptr[idx], "/L=", 3);
+ idx += 3;
+ copy = true;
}
+ else if (id == STATE_NAME) {
+ memcpy(&ptr[idx], "/ST=", 4);
+ idx += 4;
+ copy = true;
+ }
+ else if (id == ORG_NAME) {
+ memcpy(&ptr[idx], "/O=", 3);
+ idx += 3;
+ copy = true;
+ }
+ else if (id == ORGUNIT_NAME) {
+ memcpy(&ptr[idx], "/OU=", 4);
+ idx += 4;
+ copy = true;
+ }
+
+ if (copy) {
+ memcpy(&ptr[idx], source_.get_current(), strLen);
+ idx += strLen;
+ }
+
sha.Update(source_.get_current(), strLen);
source_.advance(strLen);
}
@@ -711,6 +749,8 @@ void CertDecoder::GetName(NameType nt)
source_.advance(length);
}
}
+ ptr[idx++] = 0;
+
if (nt == ISSUER)
sha.Final(issuerHash_);
else
diff --git a/extra/yassl/taocrypt/src/make.bat b/extra/yassl/taocrypt/src/make.bat
index 5a2ae580b76..3acd50fc875 100644
--- a/extra/yassl/taocrypt/src/make.bat
+++ b/extra/yassl/taocrypt/src/make.bat
@@ -1,4 +1,4 @@
-# quick and dirty build file for testing different MSDEVs
+REM quick and dirty build file for testing different MSDEVs
setlocal
set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2
diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp
index 12bcd8238f2..18a884364fa 100644
--- a/extra/yassl/taocrypt/src/template_instnt.cpp
+++ b/extra/yassl/taocrypt/src/template_instnt.cpp
@@ -30,7 +30,6 @@
#include "sha.hpp"
#include "md5.hpp"
#include "hmac.hpp"
-#include "ripemd.hpp"
#include "pwdbased.hpp"
#include "algebra.hpp"
#include "vector.hpp"