aboutsummaryrefslogtreecommitdiffstats
path: root/src/scepclient
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2009-04-17 16:11:33 +0000
committerAndreas Steffen <andreas.steffen@strongswan.org>2009-04-17 16:11:33 +0000
commit9b91b81870d4b792c9e826349c34d98b7a835e20 (patch)
tree44283bfd7b9167bccd3e02dbff1cf192b7b3df58 /src/scepclient
parentc04e75487ffab245d35461b1d84eddd1e1408ba8 (diff)
downloadstrongswan-9b91b81870d4b792c9e826349c34d98b7a835e20.tar.bz2
strongswan-9b91b81870d4b792c9e826349c34d98b7a835e20.tar.xz
ported most of the libstrongswan chunk_t macros to pluto
Diffstat (limited to 'src/scepclient')
-rw-r--r--src/scepclient/pkcs10.c6
-rw-r--r--src/scepclient/rsakey.c6
-rw-r--r--src/scepclient/scep.c12
-rw-r--r--src/scepclient/scepclient.c28
4 files changed, 27 insertions, 25 deletions
diff --git a/src/scepclient/pkcs10.c b/src/scepclient/pkcs10.c
index 4a56e701b..f7c4cca36 100644
--- a/src/scepclient/pkcs10.c
+++ b/src/scepclient/pkcs10.c
@@ -43,13 +43,13 @@ static u_char ASN1_challengePassword_oid_str[] = {
0x06,0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x07
};
-static const chunk_t ASN1_challengePassword_oid = strchunk(ASN1_challengePassword_oid_str);
+static const chunk_t ASN1_challengePassword_oid = chunk_from_buf(ASN1_challengePassword_oid_str);
static u_char ASN1_extensionRequest_oid_str[] = {
0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x0E
};
-static const chunk_t ASN1_extensionRequest_oid = strchunk(ASN1_extensionRequest_oid_str);
+static const chunk_t ASN1_extensionRequest_oid = chunk_from_buf(ASN1_extensionRequest_oid_str);
/**
* @brief Adds a subjectAltName in DER-coded form to a linked list
@@ -214,7 +214,7 @@ pkcs10_free(pkcs10_t *pkcs10)
{
if (pkcs10 != NULL)
{
- freeanychunk(pkcs10->request);
+ free(pkcs10->request.ptr);
free(pkcs10);
}
}
diff --git a/src/scepclient/rsakey.c b/src/scepclient/rsakey.c
index a7c6321f5..dff405f59 100644
--- a/src/scepclient/rsakey.c
+++ b/src/scepclient/rsakey.c
@@ -321,10 +321,12 @@ generate_rsa_private_key(int nbits, RSA_private_key_t *key)
size_t n_len = (mpz_sizeinbase(n,2)+BITS_PER_BYTE-1)/BITS_PER_BYTE;
chunk_t e_ch = mpz_to_n(e, e_len);
chunk_t n_ch = mpz_to_n(n, n_len);
+
form_keyid(e_ch, n_ch, key->pub.keyid, &key->pub.k);
- freeanychunk(e_ch);
- freeanychunk(n_ch);
+ free(e_ch.ptr);
+ free(n_ch.ptr);
}
+
/* fill in the elements of the RSA private key */
key->p = *p;
key->q = *q;
diff --git a/src/scepclient/scep.c b/src/scepclient/scep.c
index d9d872225..f603b5c29 100644
--- a/src/scepclient/scep.c
+++ b/src/scepclient/scep.c
@@ -53,11 +53,11 @@ static char ASN1_transId_oid_str[] = {
};
static const chunk_t ASN1_messageType_oid =
- strchunk(ASN1_messageType_oid_str);
+ chunk_from_buf(ASN1_messageType_oid_str);
static const chunk_t ASN1_senderNonce_oid =
- strchunk(ASN1_senderNonce_oid_str);
+ chunk_from_buf(ASN1_senderNonce_oid_str);
static const chunk_t ASN1_transId_oid =
- strchunk(ASN1_transId_oid_str);
+ chunk_from_buf(ASN1_transId_oid_str);
static const char *pkiStatus_values[] = { "0", "2", "3" };
@@ -395,8 +395,8 @@ scep_build_request(chunk_t data, chunk_t transID, scep_msg_t msg
request = pkcs7_build_signedData(envelopedData, attributes
, signer_cert, digest_alg, private_key);
- freeanychunk(envelopedData);
- freeanychunk(attributes);
+ free(envelopedData.ptr);
+ free(attributes.ptr);
return request;
}
@@ -590,7 +590,7 @@ scep_parse_response(chunk_t response, chunk_t transID, contentInfo_t *data
{
return "error parsing the scep response attributes";
}
- if (!same_chunk(transID, attrs->transID))
+ if (!chunk_equals(transID, attrs->transID))
{
return "transaction ID of scep response does not match";
}
diff --git a/src/scepclient/scepclient.c b/src/scepclient/scepclient.c
index fe979234e..7d1c2e544 100644
--- a/src/scepclient/scepclient.c
+++ b/src/scepclient/scepclient.c
@@ -148,21 +148,21 @@ exit_scepclient(err_t message, ...)
free_RSA_private_content(private_key);
free(private_key);
}
- freeanychunk(pkcs1);
- freeanychunk(pkcs7);
- freeanychunk(subject);
- freeanychunk(serialNumber);
- freeanychunk(transID);
- freeanychunk(fingerprint);
- freeanychunk(issuerAndSubject);
- freeanychunk(getCertInitial);
- if (scep_response.ptr != NULL)
- free(scep_response.ptr);
+ free(pkcs1.ptr);
+ free(pkcs7.ptr);
+ free(subject.ptr);
+ free(serialNumber.ptr);
+ free(transID.ptr);
+ free(fingerprint.ptr);
+ free(issuerAndSubject.ptr);
+ free(getCertInitial.ptr);
+ free(scep_response.ptr);
free_generalNames(subjectAltNames, TRUE);
if (x509_signer != NULL)
+ {
x509_signer->subjectAltName = NULL;
-
+ }
free_x509cert(x509_signer);
free_x509cert(x509_ca_enc);
free_x509cert(x509_ca_sig);
@@ -801,7 +801,7 @@ int main(int argc, char **argv)
exit_scepclient(ugh);
}
- clonetochunk(subject, dn.ptr, dn.len);
+ subject = chunk_clone(dn);
DBG(DBG_CONTROL,
DBG_log("building pkcs10 object:")
@@ -1007,7 +1007,7 @@ int main(int argc, char **argv)
DBG_log("transaction ID: %.*s", (int)transID.len, transID.ptr)
)
- freeanychunk(getCertInitial);
+ chunk_free(&getCertInitial);
getCertInitial = scep_build_request(issuerAndSubject
, transID, SCEP_GetCertInitial_MSG
, x509_ca_enc, pkcs7_symmetric_cipher
@@ -1047,7 +1047,7 @@ int main(int argc, char **argv)
{
exit_scepclient("error parsing the scep response");
}
- freeanychunk(certData);
+ chunk_free(&certData);
/* store the end entity certificate */
path = concatenate_paths(HOST_CERT_PATH, file_out_cert);