ported most of the libstrongswan chunk_t macros to pluto
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
+14
-14
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user