↓
|
gnutls_priority_init
|
55
|
161
|
330
|
gnutls_priority.c
|
int
gnutls_priority_init (gnutls_priority_t * priority_cache,
const char *priorities, const char **err_pos)
{
char *broken_list[MAX_ELEMENTS];
int broken_list_size = 0, i = 0, j;
char *darg = NULL;
int algo;
rmadd_func *fn;
bulk_rmadd_func *bulk_fn;
*priority_cache = gnutls_calloc (1, sizeof (struct gnutls_priority_st));
if (*priority_cache == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* for now unsafe renegotiation is default on everyone. To be removed
* when we make it the default.
*/
(*priority_cache)->sr = SR_PARTIAL;
(*priority_cache)->ssl3_record_version = 1;
if (priorities == NULL)
priorities = "NORMAL";
darg = gnutls_strdup (priorities);
if (darg == NULL)
{
gnutls_assert ();
goto error;
}
break_comma_list (darg, broken_list, &broken_list_size, MAX_ELEMENTS, ':');
/* This is our default set of protocol version, certificate types and
* compression methods.
*/
if (strcasecmp (broken_list[0], "NONE") != 0)
{
_set_priority (&(*priority_cache)->protocol, protocol_priority);
_set_priority (&(*priority_cache)->compression, comp_priority);
_set_priority (&(*priority_cache)->cert_type, cert_type_priority_default);
_set_priority (&(*priority_cache)->sign_algo, sign_priority_default);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_normal);
i = 0;
}
else
{
i = 1;
}
for (; i < broken_list_size; i++)
{
if (strcasecmp (broken_list[i], "PERFORMANCE") == 0)
{
_set_priority (&(*priority_cache)->cipher,
cipher_priority_performance);
_set_priority (&(*priority_cache)->kx, kx_priority_performance);
_set_priority (&(*priority_cache)->mac, mac_priority_normal);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_default);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_normal);
}
else if (strcasecmp (broken_list[i], "NORMAL") == 0)
{
_set_priority (&(*priority_cache)->cipher, cipher_priority_normal);
_set_priority (&(*priority_cache)->kx, kx_priority_secure);
_set_priority (&(*priority_cache)->mac, mac_priority_normal);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_default);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_normal);
}
else if (strcasecmp (broken_list[i], "SECURE256") == 0
|| strcasecmp (broken_list[i], "SECURE192") == 0)
{
_set_priority (&(*priority_cache)->cipher,
cipher_priority_secure192);
_set_priority (&(*priority_cache)->kx, kx_priority_secure);
_set_priority (&(*priority_cache)->mac, mac_priority_secure192);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_secure192);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_secure192);
}
else if (strcasecmp (broken_list[i], "SECURE128") == 0
|| strcasecmp (broken_list[i], "SECURE") == 0)
{
_set_priority (&(*priority_cache)->cipher,
cipher_priority_secure128);
_set_priority (&(*priority_cache)->kx, kx_priority_secure);
_set_priority (&(*priority_cache)->mac, mac_priority_secure128);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_secure128);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_secure128);
}
else if (strcasecmp (broken_list[i], "SUITEB128") == 0)
{
_set_priority (&(*priority_cache)->protocol, protocol_priority_suiteb);
_set_priority (&(*priority_cache)->cipher,
cipher_priority_suiteb128);
_set_priority (&(*priority_cache)->kx, kx_priority_suiteb);
_set_priority (&(*priority_cache)->mac, mac_priority_suiteb128);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_suiteb128);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_suiteb128);
}
else if (strcasecmp (broken_list[i], "SUITEB192") == 0)
{
_set_priority (&(*priority_cache)->protocol, protocol_priority_suiteb);
_set_priority (&(*priority_cache)->cipher,
cipher_priority_suiteb192);
_set_priority (&(*priority_cache)->kx, kx_priority_suiteb);
_set_priority (&(*priority_cache)->mac, mac_priority_suiteb192);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_suiteb192);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_suiteb192);
}
else if (strcasecmp (broken_list[i], "EXPORT") == 0)
{
_set_priority (&(*priority_cache)->cipher, cipher_priority_export);
_set_priority (&(*priority_cache)->kx, kx_priority_export);
_set_priority (&(*priority_cache)->mac, mac_priority_secure128);
_set_priority (&(*priority_cache)->sign_algo,
sign_priority_default);
_set_priority (&(*priority_cache)->supported_ecc, supported_ecc_normal);
} /* now check if the element is something like -ALGO */
else if (broken_list[i][0] == '!' || broken_list[i][0] == '+'
|| broken_list[i][0] == '-')
{
if (broken_list[i][0] == '+')
{
fn = prio_add;
bulk_fn = _set_priority;
}
else
{
fn = prio_remove;
bulk_fn = _clear_priorities;
}
if ((algo =
gnutls_mac_get_id (&broken_list[i][1])) != GNUTLS_MAC_UNKNOWN)
fn (&(*priority_cache)->mac, algo);
else if ((algo = gnutls_cipher_get_id (&broken_list[i][1])) !=
GNUTLS_CIPHER_UNKNOWN)
fn (&(*priority_cache)->cipher, algo);
else if ((algo = gnutls_kx_get_id (&broken_list[i][1])) !=
GNUTLS_KX_UNKNOWN)
fn (&(*priority_cache)->kx, algo);
else if (strncasecmp (&broken_list[i][1], "VERS-", 5) == 0)
{
if (strncasecmp (&broken_list[i][1], "VERS-TLS-ALL", 12) == 0)
{
bulk_fn (&(*priority_cache)->protocol,
protocol_priority);
}
else
{
if ((algo =
gnutls_protocol_get_id (&broken_list[i][6])) !=
GNUTLS_VERSION_UNKNOWN)
fn (&(*priority_cache)->protocol, algo);
else
goto error;
}
} /* now check if the element is something like -ALGO */
else if (strncasecmp (&broken_list[i][1], "COMP-", 5) == 0)
{
if (strncasecmp (&broken_list[i][1], "COMP-ALL", 8) == 0)
{
bulk_fn (&(*priority_cache)->compression,
comp_priority);
}
else
{
if ((algo =
gnutls_compression_get_id (&broken_list[i][6])) !=
GNUTLS_COMP_UNKNOWN)
fn (&(*priority_cache)->compression, algo);
else
goto error;
}
} /* now check if the element is something like -ALGO */
else if (strncasecmp (&broken_list[i][1], "CURVE-", 6) == 0)
{
if (strncasecmp (&broken_list[i][1], "CURVE-ALL", 9) == 0)
{
bulk_fn (&(*priority_cache)->supported_ecc,
supported_ecc_normal);
}
else
{
if ((algo =
_gnutls_ecc_curve_get_id (&broken_list[i][7])) !=
GNUTLS_ECC_CURVE_INVALID)
fn (&(*priority_cache)->supported_ecc, algo);
else
goto error;
}
} /* now check if the element is something like -ALGO */
else if (strncasecmp (&broken_list[i][1], "CTYPE-", 6) == 0)
{
if (strncasecmp (&broken_list[i][1], "CTYPE-ALL", 9) == 0)
{
bulk_fn (&(*priority_cache)->cert_type,
cert_type_priority_all);
}
else
{
if ((algo =
gnutls_certificate_type_get_id (&broken_list[i][7])) !=
GNUTLS_CRT_UNKNOWN)
fn (&(*priority_cache)->cert_type, algo);
else
goto error;
}
} /* now check if the element is something like -ALGO */
else if (strncasecmp (&broken_list[i][1], "SIGN-", 5) == 0)
{
if (strncasecmp (&broken_list[i][1], "SIGN-ALL", 8) == 0)
{
bulk_fn (&(*priority_cache)->sign_algo,
sign_priority_default);
}
else
{
if ((algo =
gnutls_sign_get_id (&broken_list[i][6])) !=
GNUTLS_SIGN_UNKNOWN)
fn (&(*priority_cache)->sign_algo, algo);
else
goto error;
}
}
else if (strncasecmp (&broken_list[i][1], "MAC-ALL", 7) == 0)
{
bulk_fn (&(*priority_cache)->mac,
mac_priority_normal);
}
else if (strncasecmp (&broken_list[i][1], "CIPHER-ALL", 10) == 0)
{
bulk_fn (&(*priority_cache)->cipher,
cipher_priority_normal);
}
else if (strncasecmp (&broken_list[i][1], "KX-ALL", 6) == 0)
{
bulk_fn (&(*priority_cache)->kx,
kx_priority_secure);
}
else
goto error;
}
else if (broken_list[i][0] == '%')
{
if (strcasecmp (&broken_list[i][1], "COMPAT") == 0)
{
(*priority_cache)->no_padding = 1;
(*priority_cache)->allow_large_records = 1;
}
else if (strcasecmp (&broken_list[i][1], "NO_EXTENSIONS") == 0)
{
(*priority_cache)->no_extensions = 1;
}
else if (strcasecmp (&broken_list[i][1],
"VERIFY_ALLOW_SIGN_RSA_MD5") == 0)
{
prio_add (&(*priority_cache)->sign_algo, GNUTLS_SIGN_RSA_MD5);
(*priority_cache)->additional_verify_flags |=
GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5;
}
else if (strcasecmp (&broken_list[i][1],
"SSL3_RECORD_VERSION") == 0)
(*priority_cache)->ssl3_record_version = 1;
else if (strcasecmp (&broken_list[i][1],
"LATEST_RECORD_VERSION") == 0)
(*priority_cache)->ssl3_record_version = 0;
else if (strcasecmp (&broken_list[i][1],
"VERIFY_ALLOW_X509_V1_CA_CRT") == 0)
(*priority_cache)->additional_verify_flags |=
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT;
else if (strcasecmp (&broken_list[i][1],
"UNSAFE_RENEGOTIATION") == 0)
{
(*priority_cache)->sr = SR_UNSAFE;
}
else if (strcasecmp (&broken_list[i][1], "SAFE_RENEGOTIATION") == 0)
{
(*priority_cache)->sr = SR_SAFE;
}
else if (strcasecmp (&broken_list[i][1],
"PARTIAL_RENEGOTIATION") == 0)
{
(*priority_cache)->sr = SR_PARTIAL;
}
else if (strcasecmp (&broken_list[i][1],
"DISABLE_SAFE_RENEGOTIATION") == 0)
{
(*priority_cache)->sr = SR_DISABLED;
}
else if (strcasecmp (&broken_list[i][1],
"SERVER_PRECEDENCE") == 0)
{
(*priority_cache)->server_precedence = 1;
}
else
goto error;
}
else
goto error;
}
gnutls_free (darg);
return 0;
error:
if (err_pos != NULL && i < broken_list_size)
{
*err_pos = priorities;
for (j = 0; j < i; j++)
{
(*err_pos) += strlen (broken_list[j]) + 1;
}
}
gnutls_free (darg);
gnutls_free (*priority_cache);
return GNUTLS_E_INVALID_REQUEST;
}
|
↓
|
print_extensions
|
49
|
142
|
265
|
x509/output.c
|
static void
print_extensions (gnutls_buffer_st * str, const char *prefix, int type,
cert_type_t cert)
{
int i, err;
int san_idx = 0;
int ian_idx = 0;
int proxy_idx = 0;
int basic_idx = 0;
int keyusage_idx = 0;
int keypurpose_idx = 0;
int ski_idx = 0;
int aki_idx = 0;
int crldist_idx = 0;
for (i = 0;; i++)
{
char oid[MAX_OID_SIZE] = "";
size_t sizeof_oid = sizeof (oid);
unsigned int critical;
if (type == TYPE_CRT)
err = gnutls_x509_crt_get_extension_info (cert.crt, i,
oid, &sizeof_oid,
&critical);
else if (type == TYPE_CRQ)
err = gnutls_x509_crq_get_extension_info (cert.crq, i,
oid, &sizeof_oid,
&critical);
else
{
gnutls_assert ();
return;
}
if (err < 0)
{
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
addf (str, "error: get_extension_info: %s\n",
gnutls_strerror (err));
continue;
}
if (i == 0)
addf (str, _("%s\tExtensions:\n"), prefix);
if (strcmp (oid, "2.5.29.19") == 0)
{
if (basic_idx)
{
addf (str, "error: more than one basic constraint\n");
continue;
}
addf (str, _("%s\t\tBasic Constraints (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
print_basic (str, prefix, type, cert);
basic_idx++;
}
else if (strcmp (oid, "2.5.29.14") == 0)
{
if (ski_idx)
{
addf (str, "error: more than one SKI extension\n");
continue;
}
addf (str, _("%s\t\tSubject Key Identifier (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
if (type == TYPE_CRT)
print_ski (str, cert.crt);
ski_idx++;
}
else if (strcmp (oid, "2.5.29.35") == 0)
{
if (aki_idx)
{
addf (str, "error: more than one AKI extension\n");
continue;
}
addf (str, _("%s\t\tAuthority Key Identifier (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
if (type == TYPE_CRT)
print_aki (str, TYPE_CRT, cert);
aki_idx++;
}
else if (strcmp (oid, "2.5.29.15") == 0)
{
if (keyusage_idx)
{
addf (str, "error: more than one key usage extension\n");
continue;
}
addf (str, _("%s\t\tKey Usage (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
print_key_usage (str, prefix, type, cert);
keyusage_idx++;
}
else if (strcmp (oid, "2.5.29.37") == 0)
{
if (keypurpose_idx)
{
addf (str, "error: more than one key purpose extension\n");
continue;
}
addf (str, _("%s\t\tKey Purpose (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
#ifdef ENABLE_PKI
print_key_purpose (str, prefix, type, cert);
#endif
keypurpose_idx++;
}
else if (strcmp (oid, "2.5.29.17") == 0)
{
if (san_idx)
{
addf (str, "error: more than one SKI extension\n");
continue;
}
addf (str, _("%s\t\tSubject Alternative Name (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
print_altname (str, prefix, type, cert);
san_idx++;
}
else if (strcmp (oid, "2.5.29.18") == 0)
{
if (ian_idx)
{
addf (str, "error: more than one Issuer AltName extension\n");
continue;
}
addf (str, _("%s\t\tIssuer Alternative Name (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
print_altname (str, prefix, TYPE_CRT_IAN, cert);
ian_idx++;
}
else if (strcmp (oid, "2.5.29.31") == 0)
{
if (crldist_idx)
{
addf (str, "error: more than one CRL distribution point\n");
continue;
}
addf (str, _("%s\t\tCRL Distribution points (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
#ifdef ENABLE_PKI
if (type == TYPE_CRT)
print_crldist (str, cert.crt);
#endif
crldist_idx++;
}
else if (strcmp (oid, "1.3.6.1.5.5.7.1.14") == 0)
{
if (proxy_idx)
{
addf (str, "error: more than one proxy extension\n");
continue;
}
addf (str, _("%s\t\tProxy Certificate Information (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
if (type == TYPE_CRT)
print_proxy (str, cert.crt);
proxy_idx++;
}
else if (strcmp (oid, "1.3.6.1.5.5.7.1.1") == 0)
{
addf (str, _("%s\t\tAuthority Information "
"Access (%s):\n"), prefix,
critical ? _("critical") : _("not critical"));
if (type == TYPE_CRT)
print_aia (str, cert.crt);
}
else
{
char *buffer;
size_t extlen = 0;
addf (str, _("%s\t\tUnknown extension %s (%s):\n"), prefix, oid,
critical ? _("critical") : _("not critical"));
if (type == TYPE_CRT)
err =
gnutls_x509_crt_get_extension_data (cert.crt, i, NULL, &extlen);
else if (type == TYPE_CRQ)
err =
gnutls_x509_crq_get_extension_data (cert.crq, i, NULL, &extlen);
else
{
gnutls_assert ();
return;
}
if (err < 0)
{
addf (str, "error: get_extension_data: %s\n",
gnutls_strerror (err));
continue;
}
buffer = gnutls_malloc (extlen);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
continue;
}
if (type == TYPE_CRT)
err =
gnutls_x509_crt_get_extension_data (cert.crt, i, buffer,
&extlen);
else if (type == TYPE_CRQ)
err =
gnutls_x509_crq_get_extension_data (cert.crq, i, buffer,
&extlen);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_extension_data2: %s\n",
gnutls_strerror (err));
continue;
}
addf (str, _("%s\t\t\tASCII: "), prefix);
_gnutls_buffer_asciiprint (str, buffer, extlen);
addf (str, "\n");
addf (str, _("%s\t\t\tHexdump: "), prefix);
_gnutls_buffer_hexprint (str, buffer, extlen);
adds (str, "\n");
gnutls_free (buffer);
}
}
}
|
↓
|
write_secret_key
|
44
|
79
|
122
|
opencdk/write-packet.c
|
static cdk_error_t
write_secret_key (cdk_stream_t out, cdk_pkt_seckey_t sk,
int is_subkey, int old_ctb)
{
cdk_pkt_pubkey_t pk = NULL;
size_t size = 6, npkey, nskey;
int pkttype, s2k_mode;
cdk_error_t rc;
assert (out);
assert (sk);
if (!sk->pk)
return CDK_Inv_Value;
pk = sk->pk;
if (pk->version < 2 || pk->version > 4)
return CDK_Inv_Packet;
if (DEBUG_PKT)
_gnutls_write_log ("write_secret_key:\n");
npkey = cdk_pk_get_npkey (pk->pubkey_algo);
nskey = cdk_pk_get_nskey (pk->pubkey_algo);
if (!npkey || !nskey)
{
gnutls_assert ();
return CDK_Inv_Algo;
}
if (pk->version < 4)
size += 2;
/* If the key is unprotected, the 1 extra byte:
1 octet - cipher algorithm byte (0x00)
the other bytes depend on the mode:
a) simple checksum - 2 octets
b) sha-1 checksum - 20 octets */
size = !sk->is_protected ? size + 1 : size + 1 + calc_s2ksize (sk);
size += calc_mpisize (pk->mpi, npkey);
if (sk->version == 3 || !sk->is_protected)
{
if (sk->version == 3)
{
size += 2; /* force simple checksum */
sk->protect.sha1chk = 0;
}
else
size += sk->protect.sha1chk ? 20 : 2;
size += calc_mpisize (sk->mpi, nskey);
}
else /* We do not know anything about the encrypted mpi's so we
treat the data as opaque. */
size += sk->enclen;
pkttype = is_subkey ? CDK_PKT_SECRET_SUBKEY : CDK_PKT_SECRET_KEY;
rc = pkt_write_head (out, old_ctb, size, pkttype);
if (!rc)
rc = stream_putc (out, pk->version);
if (!rc)
rc = write_32 (out, pk->timestamp);
if (!rc && pk->version < 4)
{
u16 ndays = 0;
if (pk->expiredate)
ndays = (u16) ((pk->expiredate - pk->timestamp) / 86400L);
rc = write_16 (out, ndays);
}
if (!rc)
rc = stream_putc (out, _cdk_pub_algo_to_pgp (pk->pubkey_algo));
if (!rc)
rc = write_mpibuf (out, pk->mpi, npkey);
if (!rc)
{
if (sk->is_protected == 0)
rc = stream_putc (out, 0x00);
else
{
if (is_RSA (pk->pubkey_algo) && pk->version < 4)
rc = stream_putc (out, _gnutls_cipher_to_pgp (sk->protect.algo));
else if (sk->protect.s2k)
{
s2k_mode = sk->protect.s2k->mode;
rc = stream_putc (out, sk->protect.sha1chk ? 0xFE : 0xFF);
if (!rc)
rc =
stream_putc (out, _gnutls_cipher_to_pgp (sk->protect.algo));
if (!rc)
rc = stream_putc (out, sk->protect.s2k->mode);
if (!rc)
rc = stream_putc (out, sk->protect.s2k->hash_algo);
if (!rc && (s2k_mode == 1 || s2k_mode == 3))
{
rc = stream_write (out, sk->protect.s2k->salt, 8);
if (!rc && s2k_mode == 3)
rc = stream_putc (out, sk->protect.s2k->count);
}
}
else
return CDK_Inv_Value;
if (!rc)
rc = stream_write (out, sk->protect.iv, sk->protect.ivlen);
}
}
if (!rc && sk->is_protected && pk->version == 4)
{
if (sk->encdata && sk->enclen)
rc = stream_write (out, sk->encdata, sk->enclen);
}
else
{
if (!rc)
rc = write_mpibuf (out, sk->mpi, nskey);
if (!rc)
{
if (!sk->csum)
sk->csum = _cdk_sk_get_csum (sk);
rc = write_16 (out, sk->csum);
}
}
return rc;
}
|
↓
|
print_resp
|
43
|
204
|
379
|
x509/ocsp_output.c
|
static void
print_resp (gnutls_buffer_st * str, gnutls_ocsp_resp_t resp)
{
int ret;
unsigned indx;
ret = gnutls_ocsp_resp_get_status (resp);
if (ret < 0)
{
addf (str, "error: ocsp_resp_get_status: %s\n",
gnutls_strerror (ret));
return;
}
adds (str, "\tResponse Status: ");
switch (ret)
{
case GNUTLS_OCSP_RESP_SUCCESSFUL:
adds (str, "Successful\n");
break;
case GNUTLS_OCSP_RESP_MALFORMEDREQUEST:
adds (str, "malformedRequest\n");
return;
case GNUTLS_OCSP_RESP_INTERNALERROR:
adds (str, "internalError\n");
return;
case GNUTLS_OCSP_RESP_TRYLATER:
adds (str, "tryLater\n");
return;
case GNUTLS_OCSP_RESP_SIGREQUIRED:
adds (str, "sigRequired\n");
return;
case GNUTLS_OCSP_RESP_UNAUTHORIZED:
adds (str, "unauthorized\n");
return;
default:
adds (str, "unknown\n");
return;
}
{
gnutls_datum_t oid;
ret = gnutls_ocsp_resp_get_response (resp, &oid, NULL);
if (ret < 0)
{
addf (str, "error: get_response: %s\n", gnutls_strerror (ret));
return;
}
adds (str, "\tResponse Type: ");
#define OCSP_BASIC "1.3.6.1.5.5.7.48.1.1"
if (oid.size == sizeof (OCSP_BASIC)
&& memcmp (oid.data, OCSP_BASIC, oid.size) == 0)
{
adds (str, "Basic OCSP Response\n");
gnutls_free (oid.data);
}
else
{
addf (str, "Unknown response type (%.*s)\n", oid.size, oid.data);
gnutls_free (oid.data);
return;
}
}
/* Version. */
{
int version = gnutls_ocsp_resp_get_version (resp);
if (version < 0)
addf (str, "error: get_version: %s\n", gnutls_strerror (version));
else
addf (str, _("\tVersion: %d\n"), version);
}
/* responderID */
{
gnutls_datum_t dn;
/* XXX byKey */
ret = gnutls_ocsp_resp_get_responder (resp, &dn);
if (ret < 0)
addf (str, "error: get_dn: %s\n", gnutls_strerror (ret));
else
{
addf (str, _("\tResponder ID: %.*s\n"), dn.size, dn.data);
gnutls_free (dn.data);
}
}
{
char s[42];
size_t max = sizeof (s);
struct tm t;
time_t tim = gnutls_ocsp_resp_get_produced (resp);
if (tim == (time_t) -1)
addf (str, "error: ocsp_resp_get_produced\n");
else if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\tProduced At: %s\n"), s);
}
addf (str, "\tResponses:\n");
for (indx = 0; ; indx++)
{
gnutls_digest_algorithm_t digest;
gnutls_datum_t in, ik, sn;
int cert_status;
time_t this_update;
time_t next_update;
time_t revocation_time;
int revocation_reason;
ret = gnutls_ocsp_resp_get_single (resp,
indx,
&digest, &in, &ik, &sn,
&cert_status,
&this_update,
&next_update,
&revocation_time,
&revocation_reason);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
addf (str, "\t\tCertificate ID:\n");
if (ret != GNUTLS_E_SUCCESS)
{
addf (str, "error: get_singleresponse: %s\n",
gnutls_strerror (ret));
continue;
}
addf (str, "\t\t\tHash Algorithm: %s\n",
_gnutls_digest_get_name (digest));
adds (str, "\t\t\tIssuer Name Hash: ");
_gnutls_buffer_hexprint (str, in.data, in.size);
adds (str, "\n");
adds (str, "\t\t\tIssuer Key Hash: ");
_gnutls_buffer_hexprint (str, ik.data, ik.size);
adds (str, "\n");
adds (str, "\t\t\tSerial Number: ");
_gnutls_buffer_hexprint (str, sn.data, sn.size);
adds (str, "\n");
gnutls_free (in.data);
gnutls_free (ik.data);
gnutls_free (sn.data);
{
const char *p = NULL;
switch (cert_status)
{
case GNUTLS_OCSP_CERT_GOOD:
p = "good";
break;
case GNUTLS_OCSP_CERT_REVOKED:
p = "revoked";
break;
case GNUTLS_OCSP_CERT_UNKNOWN:
p = "unknown";
break;
default:
addf (str, "\t\tCertificate Status: unexpected value %d\n",
cert_status);
break;
}
if (p)
addf (str, "\t\tCertificate Status: %s\n", p);
}
/* XXX revocation reason */
if (cert_status == GNUTLS_OCSP_CERT_REVOKED)
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (revocation_time == (time_t) -1)
addf (str, "error: revocation_time\n");
else if (gmtime_r (&revocation_time, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n",
(unsigned long) revocation_time);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n",
(unsigned long) revocation_time);
else
addf (str, _("\t\tRevocation time: %s\n"), s);
}
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (this_update == (time_t) -1)
addf (str, "error: this_update\n");
else if (gmtime_r (&this_update, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) this_update);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) this_update);
else
addf (str, _("\t\tThis Update: %s\n"), s);
}
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (next_update == (time_t) -1)
addf (str, "error: next_update\n");
else if (gmtime_r (&next_update, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) next_update);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) next_update);
else
addf (str, _("\t\tNext Update: %s\n"), s);
}
/* XXX singleRequestExtensions */
}
adds (str, "\tExtensions:\n");
for (indx = 0; ; indx++)
{
gnutls_datum_t oid;
unsigned int critical;
gnutls_datum_t data;
ret = gnutls_ocsp_resp_get_extension (resp, indx, &oid, &critical, &data);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
else if (ret != GNUTLS_E_SUCCESS)
{
addf (str, "error: get_extension: %s\n",
gnutls_strerror (ret));
continue;
}
if (memcmp (oid.data, GNUTLS_OCSP_NONCE, oid.size) == 0)
{
gnutls_datum_t nonce;
unsigned int critical;
ret = gnutls_ocsp_resp_get_nonce (resp, &critical, &nonce);
if (ret != GNUTLS_E_SUCCESS)
{
addf (str, "error: get_nonce: %s\n",
gnutls_strerror (ret));
}
else
{
addf (str, "\t\tNonce%s: ", critical ? " (critical)" : "");
_gnutls_buffer_hexprint (str, nonce.data, nonce.size);
adds (str, "\n");
gnutls_free (nonce.data);
}
}
else
{
addf (str, "\t\tUnknown extension %s (%s):\n", oid.data,
critical ? "critical" : "not critical");
addf (str, _("\t\t\tASCII: "));
_gnutls_buffer_asciiprint (str, data.data, data.size);
addf (str, "\n");
addf (str, _("\t\t\tHexdump: "));
_gnutls_buffer_hexprint (str, data.data, data.size);
adds (str, "\n");
}
gnutls_free (oid.data);
gnutls_free (data.data);
}
/* Signature. */
{
gnutls_datum_t sig;
ret = gnutls_ocsp_resp_get_signature_algorithm (resp);
if (ret < 0)
addf (str, "retor: get_signature_algorithm: %s\n",
gnutls_strerror (ret));
else
{
const char *name = gnutls_sign_algorithm_get_name (ret);
if (name == NULL)
name = _("unknown");
addf (str, _("\tSignature Algorithm: %s\n"), name);
}
if (ret == GNUTLS_SIGN_RSA_MD5 || ret == GNUTLS_SIGN_RSA_MD2)
{
adds (str, _("warning: signed using a broken signature "
"algorithm that can be forged.\n"));
}
ret = gnutls_ocsp_resp_get_signature (resp, &sig);
if (ret < 0)
addf (str, "error: get_signature: %s\n", gnutls_strerror (ret));
else
{
adds (str, _("\tSignature:\n"));
_gnutls_buffer_hexdump (str, sig.data, sig.size, "\t\t");
gnutls_free (sig.data);
}
}
/* certs */
{
gnutls_x509_crt_t *certs;
size_t ncerts, i;
gnutls_datum_t out;
ret = gnutls_ocsp_resp_get_certs (resp, &certs, &ncerts);
if (ret < 0)
addf (str, "error: get_certs: %s\n", gnutls_strerror (ret));
else
{
for (i = 0; i < ncerts; i++)
{
size_t s = 0;
ret = gnutls_x509_crt_print (certs[i], GNUTLS_CRT_PRINT_FULL,
&out);
if (ret < 0)
addf (str, "error: crt_print: %s\n", gnutls_strerror (ret));
else
{
addf (str, "%.*s", out.size, out.data);
gnutls_free (out.data);
}
ret = gnutls_x509_crt_export (certs[i], GNUTLS_X509_FMT_PEM,
NULL, &s);
if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "error: crt_export: %s\n", gnutls_strerror (ret));
else
{
out.data = gnutls_malloc (s);
if (out.data == NULL)
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
ret = gnutls_x509_crt_export (certs[i], GNUTLS_X509_FMT_PEM,
out.data, &s);
out.size = s;
addf (str, "%.*s", out.size, out.data);
gnutls_free (out.data);
}
}
gnutls_x509_crt_deinit (certs[i]);
}
gnutls_free (certs);
}
}
}
|
↓
|
keydb_parse_allsigs
|
42
|
104
|
179
|
opencdk/keydb.c
|
static cdk_error_t
keydb_parse_allsigs (cdk_kbnode_t knode, cdk_keydb_hd_t hd, int check)
{
cdk_kbnode_t node, kb;
cdk_pkt_signature_t sig;
cdk_pkt_pubkey_t pk;
cdk_subpkt_t s = NULL;
u32 expiredate = 0, curtime = (u32) gnutls_time (NULL);
u32 keyid[2];
if (!knode)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (check && !hd)
{
gnutls_assert ();
return CDK_Inv_Mode;
}
kb = cdk_kbnode_find (knode, CDK_PKT_SECRET_KEY);
if (kb)
return 0;
/* Reset */
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype == CDK_PKT_USER_ID)
node->pkt->pkt.user_id->is_revoked = 0;
else if (node->pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
node->pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY)
node->pkt->pkt.public_key->is_revoked = 0;
}
kb = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (!kb)
{
gnutls_assert ();
return CDK_Wrong_Format;
}
cdk_pk_get_keyid (kb->pkt->pkt.public_key, keyid);
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype == CDK_PKT_SIGNATURE)
{
sig = node->pkt->pkt.signature;
/* Revocation certificates for primary keys */
if (sig->sig_class == 0x20)
{
kb = cdk_kbnode_find_prev (knode, node, CDK_PKT_PUBLIC_KEY);
if (kb)
{
kb->pkt->pkt.public_key->is_revoked = 1;
if (check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
{
gnutls_assert ();
return CDK_Error_No_Key;
}
}
/* Revocation certificates for subkeys */
else if (sig->sig_class == 0x28)
{
kb = cdk_kbnode_find_prev (knode, node, CDK_PKT_PUBLIC_SUBKEY);
if (kb)
{
kb->pkt->pkt.public_key->is_revoked = 1;
if (check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
{
gnutls_assert ();
return CDK_Error_No_Key;
}
}
/* Revocation certifcates for user ID's */
else if (sig->sig_class == 0x30)
{
if (sig->keyid[0] != keyid[0] || sig->keyid[1] != keyid[1])
continue; /* revokes an earlier signature, no userID. */
kb = cdk_kbnode_find_prev (knode, node, CDK_PKT_USER_ID);
if (kb)
{
kb->pkt->pkt.user_id->is_revoked = 1;
if (check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
{
gnutls_assert ();
return CDK_Error_No_Key;
}
}
/* Direct certificates for primary keys */
else if (sig->sig_class == 0x1F)
{
kb = cdk_kbnode_find_prev (knode, node, CDK_PKT_PUBLIC_KEY);
if (kb)
{
pk = kb->pkt->pkt.public_key;
pk->is_invalid = 0;
s = cdk_subpkt_find (node->pkt->pkt.signature->hashed,
CDK_SIGSUBPKT_KEY_EXPIRE);
if (s)
{
expiredate = _cdk_buftou32 (s->d);
pk->expiredate = pk->timestamp + expiredate;
pk->has_expired = pk->expiredate > curtime ? 0 : 1;
}
if (check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
{
gnutls_assert ();
return CDK_Error_No_Key;
}
}
/* Direct certificates for subkeys */
else if (sig->sig_class == 0x18)
{
kb = cdk_kbnode_find_prev (knode, node, CDK_PKT_PUBLIC_SUBKEY);
if (kb)
{
pk = kb->pkt->pkt.public_key;
pk->is_invalid = 0;
s = cdk_subpkt_find (node->pkt->pkt.signature->hashed,
CDK_SIGSUBPKT_KEY_EXPIRE);
if (s)
{
expiredate = _cdk_buftou32 (s->d);
pk->expiredate = pk->timestamp + expiredate;
pk->has_expired = pk->expiredate > curtime ? 0 : 1;
}
if (check)
_cdk_pk_check_sig (hd, kb, node, NULL, NULL);
}
else
{
gnutls_assert ();
return CDK_Error_No_Key;
}
}
}
}
node = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (node && node->pkt->pkt.public_key->version == 3)
{
/* v3 public keys have no additonal signatures for the key directly.
we say the key is valid when we have at least a self signature. */
pk = node->pkt->pkt.public_key;
for (node = knode; node; node = node->next)
{
if (is_selfsig (node, keyid))
{
pk->is_invalid = 0;
break;
}
}
}
if (node && (node->pkt->pkt.public_key->is_revoked ||
node->pkt->pkt.public_key->has_expired))
{
/* If the primary key has been revoked, mark all subkeys as invalid
because without a primary key they are not useable */
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY)
node->pkt->pkt.public_key->is_invalid = 1;
}
}
return 0;
}
|
↓
|
parse_pkcs12
|
41
|
168
|
300
|
gnutls_x509.c
|
static int
parse_pkcs12 (gnutls_certificate_credentials_t res,
gnutls_pkcs12_t p12,
const char *password,
gnutls_x509_privkey_t * key,
gnutls_x509_crt_t * cert, gnutls_x509_crl_t * crl)
{
gnutls_pkcs12_bag_t bag = NULL;
int idx = 0;
int ret;
size_t cert_id_size = 0;
size_t key_id_size = 0;
opaque cert_id[20];
opaque key_id[20];
int privkey_ok = 0;
*cert = NULL;
*key = NULL;
*crl = NULL;
/* find the first private key */
for (;;)
{
int elements_in_bag;
int i;
ret = gnutls_pkcs12_bag_init (&bag);
if (ret < 0)
{
bag = NULL;
gnutls_assert ();
goto done;
}
ret = gnutls_pkcs12_get_bag (p12, idx, bag);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
if (ret < 0)
{
gnutls_assert ();
goto done;
}
ret = gnutls_pkcs12_bag_get_type (bag, 0);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
if (ret == GNUTLS_BAG_ENCRYPTED)
{
ret = gnutls_pkcs12_bag_decrypt (bag, password);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
}
elements_in_bag = gnutls_pkcs12_bag_get_count (bag);
if (elements_in_bag < 0)
{
gnutls_assert ();
goto done;
}
for (i = 0; i < elements_in_bag; i++)
{
int type;
gnutls_datum_t data;
type = gnutls_pkcs12_bag_get_type (bag, i);
if (type < 0)
{
gnutls_assert ();
goto done;
}
ret = gnutls_pkcs12_bag_get_data (bag, i, &data);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
switch (type)
{
case GNUTLS_BAG_PKCS8_ENCRYPTED_KEY:
case GNUTLS_BAG_PKCS8_KEY:
if (*key != NULL) /* too simple to continue */
{
gnutls_assert ();
break;
}
ret = gnutls_x509_privkey_init (key);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
ret = gnutls_x509_privkey_import_pkcs8
(*key, &data, GNUTLS_X509_FMT_DER, password,
type == GNUTLS_BAG_PKCS8_KEY ? GNUTLS_PKCS_PLAIN : 0);
if (ret < 0)
{
gnutls_assert ();
gnutls_x509_privkey_deinit (*key);
goto done;
}
key_id_size = sizeof (key_id);
ret =
gnutls_x509_privkey_get_key_id (*key, 0, key_id,
&key_id_size);
if (ret < 0)
{
gnutls_assert ();
gnutls_x509_privkey_deinit (*key);
goto done;
}
privkey_ok = 1; /* break */
break;
default:
break;
}
}
idx++;
gnutls_pkcs12_bag_deinit (bag);
if (privkey_ok != 0) /* private key was found */
break;
}
if (privkey_ok == 0) /* no private key */
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
/* now find the corresponding certificate
*/
idx = 0;
bag = NULL;
for (;;)
{
int elements_in_bag;
int i;
ret = gnutls_pkcs12_bag_init (&bag);
if (ret < 0)
{
bag = NULL;
gnutls_assert ();
goto done;
}
ret = gnutls_pkcs12_get_bag (p12, idx, bag);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
if (ret < 0)
{
gnutls_assert ();
goto done;
}
ret = gnutls_pkcs12_bag_get_type (bag, 0);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
if (ret == GNUTLS_BAG_ENCRYPTED)
{
ret = gnutls_pkcs12_bag_decrypt (bag, password);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
}
elements_in_bag = gnutls_pkcs12_bag_get_count (bag);
if (elements_in_bag < 0)
{
gnutls_assert ();
goto done;
}
for (i = 0; i < elements_in_bag; i++)
{
int type;
gnutls_datum_t data;
type = gnutls_pkcs12_bag_get_type (bag, i);
if (type < 0)
{
gnutls_assert ();
goto done;
}
ret = gnutls_pkcs12_bag_get_data (bag, i, &data);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
switch (type)
{
case GNUTLS_BAG_CERTIFICATE:
if (*cert != NULL) /* no need to set it again */
{
gnutls_assert ();
break;
}
ret = gnutls_x509_crt_init (cert);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
ret =
gnutls_x509_crt_import (*cert, &data, GNUTLS_X509_FMT_DER);
if (ret < 0)
{
gnutls_assert ();
gnutls_x509_crt_deinit (*cert);
goto done;
}
/* check if the key id match */
cert_id_size = sizeof (cert_id);
ret =
gnutls_x509_crt_get_key_id (*cert, 0, cert_id, &cert_id_size);
if (ret < 0)
{
gnutls_assert ();
gnutls_x509_crt_deinit (*cert);
goto done;
}
if (memcmp (cert_id, key_id, cert_id_size) != 0)
{ /* they don't match - skip the certificate */
gnutls_x509_crt_deinit (*cert);
*cert = NULL;
}
break;
case GNUTLS_BAG_CRL:
if (*crl != NULL)
{
gnutls_assert ();
break;
}
ret = gnutls_x509_crl_init (crl);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
ret = gnutls_x509_crl_import (*crl, &data, GNUTLS_X509_FMT_DER);
if (ret < 0)
{
gnutls_assert ();
gnutls_x509_crl_deinit (*crl);
goto done;
}
break;
case GNUTLS_BAG_ENCRYPTED:
/* XXX Bother to recurse one level down? Unlikely to
use the same password anyway. */
case GNUTLS_BAG_EMPTY:
default:
break;
}
}
idx++;
gnutls_pkcs12_bag_deinit (bag);
}
ret = 0;
done:
if (bag)
gnutls_pkcs12_bag_deinit (bag);
return ret;
}
|
↓
|
print_crl
|
41
|
165
|
296
|
x509/output.c
|
static void
print_crl (gnutls_buffer_st * str, gnutls_x509_crl_t crl, int notsigned)
{
/* Version. */
{
int version = gnutls_x509_crl_get_version (crl);
if (version == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
adds (str, _("\tVersion: 1 (default)\n"));
else if (version < 0)
addf (str, "error: get_version: %s\n", gnutls_strerror (version));
else
addf (str, _("\tVersion: %d\n"), version);
}
/* Issuer. */
if (!notsigned)
{
char *dn;
size_t dn_size = 0;
int err;
err = gnutls_x509_crl_get_issuer_dn (crl, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "error: get_issuer_dn: %s\n", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "error: malloc (%d): %s\n", (int) dn_size,
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_x509_crl_get_issuer_dn (crl, dn, &dn_size);
if (err < 0)
addf (str, "error: get_issuer_dn: %s\n",
gnutls_strerror (err));
else
addf (str, _("\tIssuer: %s\n"), dn);
}
gnutls_free (dn);
}
}
/* Validity. */
{
time_t tim;
adds (str, _("\tUpdate dates:\n"));
tim = gnutls_x509_crl_get_this_update (crl);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tIssued: %s\n"), s);
}
tim = gnutls_x509_crl_get_next_update (crl);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (tim == -1)
addf (str, "\t\tNo next update time.\n");
else if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tNext at: %s\n"), s);
}
}
/* Extensions. */
if (gnutls_x509_crl_get_version (crl) >= 2)
{
size_t i;
int err = 0;
int aki_idx = 0;
int crl_nr = 0;
for (i = 0;; i++)
{
char oid[MAX_OID_SIZE] = "";
size_t sizeof_oid = sizeof (oid);
unsigned int critical;
err = gnutls_x509_crl_get_extension_info (crl, i,
oid, &sizeof_oid,
&critical);
if (err < 0)
{
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
addf (str, "error: get_extension_info: %s\n",
gnutls_strerror (err));
continue;
}
if (i == 0)
adds (str, _("\tExtensions:\n"));
if (strcmp (oid, "2.5.29.20") == 0)
{
char nr[128];
size_t nr_size = sizeof (nr);
if (crl_nr)
{
addf (str, "error: more than one CRL number\n");
continue;
}
err = gnutls_x509_crl_get_number (crl, nr, &nr_size, &critical);
addf (str, _("\t\tCRL Number (%s): "),
critical ? _("critical") : _("not critical"));
if (err < 0)
addf (str, "error: get_number: %s\n", gnutls_strerror (err));
else
{
_gnutls_buffer_hexprint (str, nr, nr_size);
addf (str, "\n");
}
crl_nr++;
}
else if (strcmp (oid, "2.5.29.35") == 0)
{
cert_type_t ccert;
if (aki_idx)
{
addf (str, "error: more than one AKI extension\n");
continue;
}
addf (str, _("\t\tAuthority Key Identifier (%s):\n"),
critical ? _("critical") : _("not critical"));
ccert.crl = crl;
print_aki (str, TYPE_CRL, ccert);
aki_idx++;
}
else
{
char *buffer;
size_t extlen = 0;
addf (str, _("\t\tUnknown extension %s (%s):\n"), oid,
critical ? _("critical") : _("not critical"));
err = gnutls_x509_crl_get_extension_data (crl, i,
NULL, &extlen);
if (err < 0)
{
addf (str, "error: get_extension_data: %s\n",
gnutls_strerror (err));
continue;
}
buffer = gnutls_malloc (extlen);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
continue;
}
err = gnutls_x509_crl_get_extension_data (crl, i,
buffer, &extlen);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_extension_data2: %s\n",
gnutls_strerror (err));
continue;
}
adds (str, _("\t\t\tASCII: "));
_gnutls_buffer_asciiprint (str, buffer, extlen);
adds (str, "\n");
adds (str, _("\t\t\tHexdump: "));
_gnutls_buffer_hexprint (str, buffer, extlen);
adds (str, "\n");
gnutls_free (buffer);
}
}
}
/* Revoked certificates. */
{
int num = gnutls_x509_crl_get_crt_count (crl);
int j;
if (num)
addf (str, _("\tRevoked certificates (%d):\n"), num);
else
adds (str, _("\tNo revoked certificates.\n"));
for (j = 0; j < num; j++)
{
char serial[128];
size_t serial_size = sizeof (serial);
int err;
time_t tim;
err = gnutls_x509_crl_get_crt_serial (crl, j, serial,
&serial_size, &tim);
if (err < 0)
addf (str, "error: get_crt_serial: %s\n", gnutls_strerror (err));
else
{
char s[42];
size_t max = sizeof (s);
struct tm t;
adds (str, _("\t\tSerial Number (hex): "));
_gnutls_buffer_hexprint (str, serial, serial_size);
adds (str, "\n");
if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tRevoked at: %s\n"), s);
}
}
}
/* Signature. */
if (!notsigned)
{
int err;
size_t size = 0;
char *buffer = NULL;
err = gnutls_x509_crl_get_signature_algorithm (crl);
if (err < 0)
addf (str, "error: get_signature_algorithm: %s\n",
gnutls_strerror (err));
else
{
const char *name = gnutls_sign_algorithm_get_name (err);
if (name == NULL)
name = _("unknown");
addf (str, _("\tSignature Algorithm: %s\n"), name);
}
if (err == GNUTLS_SIGN_RSA_MD5 || err == GNUTLS_SIGN_RSA_MD2)
{
adds (str, _("warning: signed using a broken signature "
"algorithm that can be forged.\n"));
}
err = gnutls_x509_crl_get_signature (crl, buffer, &size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
addf (str, "error: get_signature: %s\n", gnutls_strerror (err));
return;
}
buffer = gnutls_malloc (size);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
return;
}
err = gnutls_x509_crl_get_signature (crl, buffer, &size);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_signature2: %s\n", gnutls_strerror (err));
return;
}
adds (str, _("\tSignature:\n"));
_gnutls_buffer_hexdump (str, buffer, size, "\t\t");
gnutls_free (buffer);
}
}
|
↓
|
ecc_mulmod
|
36
|
91
|
153
|
nettle/ecc_mulmod.c
|
int
ecc_mulmod (mpz_t k, ecc_point * G, ecc_point * R, mpz_t a, mpz_t modulus,
int map)
{
ecc_point *tG, *M[8];
int i, j, err, bitidx;
int first, bitbuf, bitcpy, mode;
if (k == NULL || G == NULL || R == NULL || modulus == NULL)
return -1;
/* alloc ram for window temps */
for (i = 0; i < 8; i++) {
M[i] = ecc_new_point();
if (M[i] == NULL) {
for (j = 0; j < i; j++) {
ecc_del_point(M[j]);
}
return -1;
}
}
/* make a copy of G incase R==G */
tG = ecc_new_point();
if (tG == NULL)
{
err = -1;
goto done;
}
/* tG = G and convert to montgomery */
mpz_set (tG->x, G->x);
mpz_set (tG->y, G->y);
mpz_set (tG->z, G->z);
/* calc the M tab, which holds kG for k==8..15 */
/* M[0] == 8G */
if ((err = ecc_projective_dbl_point (tG, M[0], a, modulus)) != 0)
goto done;
if ((err = ecc_projective_dbl_point (M[0], M[0], a, modulus)) != 0)
goto done;
if ((err = ecc_projective_dbl_point (M[0], M[0], a, modulus)) != 0)
goto done;
/* now find (8+k)G for k=1..7 */
for (j = 9; j < 16; j++) {
if (ecc_projective_add_point(M[j-9], tG, M[j-8], a, modulus) != 0)
goto done;
}
/* setup sliding window */
mode = 0;
bitidx = mpz_size (k) * GMP_NUMB_BITS - 1;
bitcpy = bitbuf = 0;
first = 1;
/* perform ops */
for (;;) {
/* grab next digit as required */
if (bitidx == -1) {
break;
}
/* grab the next msb from the ltiplicand */
i = mpz_tstbit (k, bitidx--);
/* skip leading zero bits */
if (mode == 0 && i == 0) {
continue;
}
/* if the bit is zero and mode == 1 then we double */
if (mode == 1 && i == 0) {
if ((err = ecc_projective_dbl_point(R, R, a, modulus)) != 0)
goto done;
continue;
}
/* else we add it to the window */
bitbuf |= (i << (WINSIZE - ++bitcpy));
mode = 2;
if (bitcpy == WINSIZE) {
/* if this is the first window we do a simple copy */
if (first == 1) {
/* R = kG [k = first window] */
mpz_set(R->x, M[bitbuf-8]->x);
mpz_set(R->y, M[bitbuf-8]->y);
mpz_set(R->z, M[bitbuf-8]->z);
first = 0;
} else {
/* normal window */
/* ok window is filled so double as required and add */
/* double first */
for (j = 0; j < WINSIZE; j++) {
if ((err = ecc_projective_dbl_point(R, R, a, modulus)) != 0)
goto done;
}
/* then add, bitbuf will be 8..15 [8..2^WINSIZE] guaranteed */
if ((err = ecc_projective_add_point(R, M[bitbuf-8], R, a, modulus)) != 0)
goto done;
}
/* empty window and reset */
bitcpy = bitbuf = 0;
mode = 1;
}
}
/* if bits remain then double/add */
if (mode == 2 && bitcpy > 0) {
/* double then add */
for (j = 0; j < bitcpy; j++) {
/* only double if we have had at least one add first */
if (first == 0) {
if ((err = ecc_projective_dbl_point(R, R, a, modulus)) != 0)
goto done;
}
bitbuf <<= 1;
if ((bitbuf & (1 << WINSIZE)) != 0) {
if (first == 1){
/* first add, so copy */
mpz_set(R->x, tG->x);
mpz_set(R->y, tG->y);
mpz_set(R->z, tG->z);
first = 0;
} else {
/* then add */
if ((err = ecc_projective_add_point(R, tG, R, a, modulus)) != 0)
goto done;
}
}
}
}
/* map R back from projective space */
if (map) {
err = ecc_map(R, modulus);
} else {
err = 0;
}
done:
ecc_del_point(tG);
for (i = 0; i < 8; i++) {
ecc_del_point(M[i]);
}
return err;
}
|
↓
|
find_objs
|
36
|
163
|
297
|
pkcs11.c
|
static int
find_objs (struct ck_function_list * module, ck_session_handle_t pks,
struct token_info *info, struct ck_info *lib_info, void *input)
{
struct crt_find_data_st *find_data = input;
struct ck_attribute a[4];
struct ck_attribute *attr;
ck_object_class_t class = -1;
ck_certificate_type_t type = -1;
unsigned int trusted;
ck_rv_t rv;
ck_object_handle_t obj;
unsigned long count;
opaque *cert_data;
char certid_tmp[PKCS11_ID_SIZE];
char label_tmp[PKCS11_LABEL_SIZE];
int ret, i;
struct pkey_list plist; /* private key holder */
int tot_values = 0;
if (info == NULL)
{ /* final call */
if (find_data->current <= *find_data->n_list)
ret = 0;
else
ret = GNUTLS_E_SHORT_MEMORY_BUFFER;
*find_data->n_list = find_data->current;
return ret;
}
/* do not bother reading the token if basic fields do not match
*/
if (!p11_kit_uri_match_token_info (find_data->info, &info->tinfo) ||
!p11_kit_uri_match_module_info (find_data->info, lib_info))
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
memset (&plist, 0, sizeof (plist));
if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY)
{
ret = find_privkeys (module, pks, info, &plist);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (plist.key_ids_size == 0)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
}
cert_data = gnutls_malloc (MAX_CERT_SIZE);
if (cert_data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* Find objects with cert class and X.509 cert type. */
tot_values = 0;
if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_CRT_ALL
|| find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY)
{
class = CKO_CERTIFICATE;
type = CKC_X_509;
trusted = 1;
a[tot_values].type = CKA_CLASS;
a[tot_values].value = &class;
a[tot_values].value_len = sizeof class;
tot_values++;
a[tot_values].type = CKA_CERTIFICATE_TYPE;
a[tot_values].value = &type;
a[tot_values].value_len = sizeof type;
tot_values++;
}
else if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED)
{
class = CKO_CERTIFICATE;
type = CKC_X_509;
trusted = 1;
a[tot_values].type = CKA_CLASS;
a[tot_values].value = &class;
a[tot_values].value_len = sizeof class;
tot_values++;
a[tot_values].type = CKA_TRUSTED;
a[tot_values].value = &trusted;
a[tot_values].value_len = sizeof trusted;
tot_values++;
}
else if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_PUBKEY)
{
class = CKO_PUBLIC_KEY;
a[tot_values].type = CKA_CLASS;
a[tot_values].value = &class;
a[tot_values].value_len = sizeof class;
tot_values++;
}
else if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_PRIVKEY)
{
class = CKO_PRIVATE_KEY;
a[tot_values].type = CKA_CLASS;
a[tot_values].value = &class;
a[tot_values].value_len = sizeof class;
tot_values++;
}
else if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_ALL)
{
if (class != -1)
{
a[tot_values].type = CKA_CLASS;
a[tot_values].value = &class;
a[tot_values].value_len = sizeof class;
tot_values++;
}
if (type != -1)
{
a[tot_values].type = CKA_CERTIFICATE_TYPE;
a[tot_values].value = &type;
a[tot_values].value_len = sizeof type;
tot_values++;
}
}
else
{
gnutls_assert ();
ret = GNUTLS_E_INVALID_REQUEST;
goto fail;
}
attr = p11_kit_uri_get_attribute (find_data->info, CKA_ID);
if (attr != NULL)
{
memcpy (a + tot_values, attr, sizeof (struct ck_attribute));
tot_values++;
}
rv = pkcs11_find_objects_init (module, pks, a, tot_values);
if (rv != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("pk11: FindObjectsInit failed.\n");
return pkcs11_rv_to_err (rv);
}
while (pkcs11_find_objects (module, pks, &obj, 1, &count) == CKR_OK && count == 1)
{
gnutls_datum_t label, id, value;
a[0].type = CKA_LABEL;
a[0].value = label_tmp;
a[0].value_len = sizeof label_tmp;
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
label.data = a[0].value;
label.size = a[0].value_len;
}
else
{
label.data = NULL;
label.size = 0;
}
a[0].type = CKA_ID;
a[0].value = certid_tmp;
a[0].value_len = sizeof certid_tmp;
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
id.data = a[0].value;
id.size = a[0].value_len;
}
else
{
id.data = NULL;
id.size = 0;
}
a[0].type = CKA_VALUE;
a[0].value = cert_data;
a[0].value_len = MAX_CERT_SIZE;
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
value.data = a[0].value;
value.size = a[0].value_len;
}
else
{
value.data = NULL;
value.size = 0;
}
if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_ALL)
{
a[0].type = CKA_CLASS;
a[0].value = &class;
a[0].value_len = sizeof class;
pkcs11_get_attribute_value (module, pks, obj, a, 1);
}
if (find_data->flags == GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY)
{
for (i = 0; i < plist.key_ids_size; i++)
{
if (plist.key_ids[i].length !=
a[1].value_len
|| memcmp (plist.key_ids[i].data,
a[1].value, a[1].value_len) != 0)
{
/* not found */
continue;
}
}
}
if (find_data->current < *find_data->n_list)
{
ret =
gnutls_pkcs11_obj_init (&find_data->p_list[find_data->current]);
if (ret < 0)
{
gnutls_assert ();
goto fail;
}
if (class == CKO_PUBLIC_KEY)
{
ret =
pkcs11_obj_import_pubkey (module, pks, obj,
find_data->p_list
[find_data->current],
&id, &label,
&info->tinfo, lib_info);
}
else
{
ret =
pkcs11_obj_import (class,
find_data->p_list
[find_data->current],
&value, &id, &label,
&info->tinfo, lib_info);
}
if (ret < 0)
{
gnutls_assert ();
goto fail;
}
}
find_data->current++;
}
gnutls_free (cert_data);
pkcs11_find_objects_final (module, pks);
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; /* continue until all tokens have been checked */
fail:
gnutls_free (cert_data);
pkcs11_find_objects_final (module, pks);
if (plist.key_ids != NULL)
{
for (i = 0; i < plist.key_ids_size; i++)
{
_gnutls_buffer_clear (&plist.key_ids[i]);
}
gnutls_free (plist.key_ids);
}
for (i = 0; i < find_data->current; i++)
{
gnutls_pkcs11_obj_deinit (find_data->p_list[i]);
}
find_data->current = 0;
return ret;
}
|
↓
|
call_get_cert_callback
|
33
|
104
|
218
|
auth/cert.c
|
static int
call_get_cert_callback (gnutls_session_t session,
const gnutls_datum_t * issuers_dn,
int issuers_dn_length,
gnutls_pk_algorithm_t * pk_algos, int pk_algos_length)
{
unsigned i;
gnutls_pcert_st *local_certs = NULL;
gnutls_privkey_t local_key = NULL;
int ret = GNUTLS_E_INTERNAL_ERROR;
gnutls_certificate_type_t type = gnutls_certificate_type_get (session);
gnutls_certificate_credentials_t cred;
gnutls_retr2_st st2;
gnutls_pcert_st *pcert = NULL;
unsigned int pcert_length = 0;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
memset (&st2, 0, sizeof (st2));
if (cred->get_cert_callback2)
{
/* we avoid all allocations and transformations */
ret = cred->get_cert_callback2 (session, issuers_dn, issuers_dn_length,
pk_algos, pk_algos_length,
&pcert, &pcert_length, &local_key);
if (ret < 0)
return gnutls_assert_val (GNUTLS_E_USER_ERROR);
if (pcert_length > 0 && type != pcert[0].type)
return gnutls_assert_val (GNUTLS_E_INVALID_REQUEST);
if (pcert_length == 0)
{
pcert = NULL;
local_key = NULL;
}
_gnutls_selected_certs_set (session, pcert, pcert_length, local_key, 0);
return 0;
}
else if (cred->get_cert_callback)
{
ret = cred->get_cert_callback (session, issuers_dn, issuers_dn_length,
pk_algos, pk_algos_length, &st2);
}
else
{ /* compatibility mode */
gnutls_retr_st st;
memset (&st, 0, sizeof (st));
if (session->security_parameters.entity == GNUTLS_SERVER)
{
if (cred->server_get_cert_callback == NULL)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
ret = cred->server_get_cert_callback (session, &st);
if (ret >= 0)
st_to_st2 (&st2, &st);
}
else
{ /* CLIENT */
if (cred->client_get_cert_callback == NULL)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
ret = cred->client_get_cert_callback (session,
issuers_dn, issuers_dn_length,
pk_algos, pk_algos_length,
&st);
if (ret >= 0)
st_to_st2 (&st2, &st);
}
}
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_USER_ERROR;
}
if (st2.ncerts == 0)
return 0; /* no certificate was selected */
if (type != st2.cert_type)
{
gnutls_assert ();
ret = GNUTLS_E_INVALID_REQUEST;
goto cleanup;
}
if (type == GNUTLS_CRT_X509)
{
local_certs = alloc_and_load_x509_certs (st2.cert.x509, st2.ncerts);
}
else
{ /* PGP */
if (st2.ncerts > 1)
{
gnutls_assert ();
ret = GNUTLS_E_INVALID_REQUEST;
goto cleanup;
}
#ifdef ENABLE_OPENPGP
{
local_certs = alloc_and_load_pgp_certs (st2.cert.pgp);
}
#else
ret = GNUTLS_E_UNIMPLEMENTED_FEATURE;
goto cleanup;
#endif
}
if (local_certs == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
switch (st2.key_type)
{
case GNUTLS_PRIVKEY_OPENPGP:
#ifdef ENABLE_OPENPGP
if (st2.key.pgp != NULL)
{
local_key = alloc_and_load_pgp_key (st2.key.pgp, st2.deinit_all);
if (local_key == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto cleanup;
}
}
#endif
break;
case GNUTLS_PRIVKEY_PKCS11:
#ifdef ENABLE_PKCS11
if (st2.key.pkcs11 != NULL)
{
local_key =
alloc_and_load_pkcs11_key (st2.key.pkcs11, st2.deinit_all);
if (local_key == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto cleanup;
}
}
#endif
break;
case GNUTLS_PRIVKEY_X509:
if (st2.key.x509 != NULL)
{
local_key = alloc_and_load_x509_key (st2.key.x509, st2.deinit_all);
if (local_key == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto cleanup;
}
}
break;
default:
gnutls_assert();
ret = GNUTLS_E_INVALID_REQUEST;
goto cleanup;
}
_gnutls_selected_certs_set (session, local_certs,
(local_certs != NULL) ? st2.ncerts : 0,
local_key, 1);
ret = 0;
cleanup:
if (st2.cert_type == GNUTLS_CRT_X509)
{
if (st2.deinit_all)
{
for (i = 0; i < st2.ncerts; i++)
{
gnutls_x509_crt_deinit (st2.cert.x509[i]);
}
gnutls_free(st2.cert.x509);
}
}
else
{
#ifdef ENABLE_OPENPGP
if (st2.deinit_all)
{
gnutls_openpgp_crt_deinit (st2.cert.pgp);
}
#endif
}
if (ret < 0)
{
if (local_key != NULL)
gnutls_privkey_deinit (local_key);
}
return ret;
}
|
↓
|
_gnutls_verify_certificate2
|
33
|
84
|
164
|
x509/verify.c
|
static int
_gnutls_verify_certificate2 (gnutls_x509_crt_t cert,
const gnutls_x509_crt_t * trusted_cas,
int tcas_size, unsigned int flags,
unsigned int *output,
gnutls_x509_crt_t * _issuer,
time_t now,
gnutls_verify_output_function func)
{
gnutls_datum_t cert_signed_data = { NULL, 0 };
gnutls_datum_t cert_signature = { NULL, 0 };
gnutls_x509_crt_t issuer = NULL;
int issuer_version, result, hash_algo;
unsigned int out = 0;
if (output)
*output = 0;
if (tcas_size >= 1)
issuer = find_issuer (cert, trusted_cas, tcas_size);
else
{
gnutls_assert ();
out = GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
if (output)
*output |= out;
result = 0;
goto cleanup;
}
/* issuer is not in trusted certificate
* authorities.
*/
if (issuer == NULL)
{
out = GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
if (output)
*output |= out;
gnutls_assert ();
result = 0;
goto cleanup;
}
if (_issuer != NULL)
*_issuer = issuer;
issuer_version = gnutls_x509_crt_get_version (issuer);
if (issuer_version < 0)
{
gnutls_assert ();
return issuer_version;
}
if (!(flags & GNUTLS_VERIFY_DISABLE_CA_SIGN) &&
((flags & GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT)
|| issuer_version != 1))
{
if (check_if_ca (cert, issuer, flags) == 0)
{
gnutls_assert ();
out = GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_INVALID;
if (output)
*output |= out;
result = 0;
goto cleanup;
}
}
result =
_gnutls_x509_get_signed_data (cert->cert, "tbsCertificate",
&cert_signed_data);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result =
_gnutls_x509_get_signature (cert->cert, "signature", &cert_signature);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_x509_get_signature_algorithm(cert->cert, "signatureAlgorithm.algorithm");
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
hash_algo = _gnutls_sign_get_hash_algorithm(result);
result =
_gnutls_x509_verify_data (hash_algo, &cert_signed_data, &cert_signature,
issuer);
if (result == GNUTLS_E_PK_SIG_VERIFY_FAILED)
{
gnutls_assert ();
out |= GNUTLS_CERT_INVALID;
/* error. ignore it */
if (output)
*output |= out;
result = 0;
}
else if (result < 0)
{
gnutls_assert();
goto cleanup;
}
/* If the certificate is not self signed check if the algorithms
* used are secure. If the certificate is self signed it doesn't
* really matter.
*/
if (is_issuer (cert, cert) == 0)
{
int sigalg;
sigalg = gnutls_x509_crt_get_signature_algorithm (cert);
if (((sigalg == GNUTLS_SIGN_RSA_MD2) &&
!(flags & GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2)) ||
((sigalg == GNUTLS_SIGN_RSA_MD5) &&
!(flags & GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5)))
{
out = GNUTLS_CERT_INSECURE_ALGORITHM | GNUTLS_CERT_INVALID;
if (output)
*output |= out;
result = 0;
}
}
/* Check activation/expiration times
*/
if (!(flags & GNUTLS_VERIFY_DISABLE_TIME_CHECKS))
{
/* check the time of the issuer first */
if (!(flags & GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS))
{
out |= check_time (issuer, now);
if (out != 0)
{
result = 0;
if (output) *output |= out;
}
}
out |= check_time (cert, now);
if (out != 0)
{
result = 0;
if (output) *output |= out;
}
}
cleanup:
if (result >= 0 && func) func(cert, issuer, NULL, out);
_gnutls_free_datum (&cert_signed_data);
_gnutls_free_datum (&cert_signature);
return result;
}
|
↓
|
armor_decode
|
33
|
80
|
132
|
opencdk/armor.c
|
static cdk_error_t
armor_decode (void *data, FILE * in, FILE * out)
{
armor_filter_t *afx = data;
const char *s;
char buf[127];
byte raw[128], crcbuf[4];
u32 crc2 = 0;
ssize_t nread = 0;
int i, pgp_data = 0;
cdk_error_t rc = 0;
int len;
if (!afx)
{
gnutls_assert ();
return CDK_Inv_Value;
}
_gnutls_buffers_log ("armor filter: decode\n");
fseek (in, 0, SEEK_SET);
/* Search the begin of the message */
while (!feof (in) && !pgp_data)
{
s = fgets (buf, DIM (buf) - 1, in);
if (!s)
break;
afx->idx = search_header (buf, armor_begin);
if (afx->idx >= 0)
pgp_data = 1;
}
if (feof (in) || !pgp_data)
{
return CDK_Armor_Error; /* no data found */
}
/* Parse header until the empty line is reached */
while (!feof (in))
{
s = fgets (buf, DIM (buf) - 1, in);
if (!s)
return CDK_EOF;
if (strcmp (s, LF) == 0 || strcmp (s, ALTLF) == 0)
{
rc = 0;
break; /* empty line */
}
/* From RFC2440: OpenPGP should consider improperly formatted Armor
Headers to be corruption of the ASCII Armor. A colon and a single
space separate the key and value. */
if (!strstr (buf, ": "))
{
gnutls_assert ();
return CDK_Armor_Error;
}
rc = CDK_General_Error;
for (i = 0; (s = valid_headers[i]); i++)
{
if (!strncmp (s, buf, strlen (s)))
rc = 0;
}
if (rc)
{
/* From RFC2440: Unknown keys should be reported to the user,
but OpenPGP should continue to process the message. */
_cdk_log_info ("unknown header: `%s'\n", buf);
rc = 0;
}
}
/* Read the data body */
while (!feof (in))
{
s = fgets (buf, DIM (buf) - 1, in);
if (!s)
break;
len = strlen(buf);
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
if (buf[len - 1] == '\r')
buf[len - 1] = '\0';
if (buf[0] == '=' && strlen (s) == 5)
{ /* CRC */
memset (crcbuf, 0, sizeof (crcbuf));
base64_decode (crcbuf, buf + 1);
crc2 = (crcbuf[0] << 16) | (crcbuf[1] << 8) | crcbuf[2];
break; /* stop here */
}
else
{
nread = base64_decode (raw, buf);
if (nread == -1 || nread == 0)
break;
afx->crc = update_crc (afx->crc, raw, nread);
fwrite (raw, 1, nread, out);
}
}
/* Search the tail of the message */
s = fgets (buf, DIM (buf) - 1, in);
if (s)
{
int len = strlen(buf);
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
if (buf[len - 1] == '\r')
buf[len - 1] = '\0';
rc = CDK_General_Error;
afx->idx2 = search_header (buf, armor_end);
if (afx->idx2 >= 0)
rc = 0;
}
/* This catches error when no tail was found or the header is
different then the tail line. */
if (rc || afx->idx != afx->idx2)
rc = CDK_Armor_Error;
afx->crc_okay = (afx->crc == crc2) ? 1 : 0;
if (!afx->crc_okay && !rc)
{
_gnutls_buffers_log ("file crc=%08X afx_crc=%08X\n",
(unsigned int) crc2, (unsigned int) afx->crc);
rc = CDK_Armor_CRC_Error;
}
return rc;
}
|
↓
|
read_secret_key
|
32
|
91
|
130
|
opencdk/read-packet.c
|
static cdk_error_t
read_secret_key (cdk_stream_t inp, size_t pktlen, cdk_pkt_seckey_t sk)
{
size_t p1, p2, nread;
int i, nskey;
int rc;
if (!inp || !sk || !sk->pk)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_secret_key: %d octets\n", (int) pktlen);
p1 = cdk_stream_tell (inp);
rc = read_public_key (inp, pktlen, sk->pk);
if (rc)
return rc;
sk->s2k_usage = cdk_stream_getc (inp);
sk->protect.sha1chk = 0;
if (sk->s2k_usage == 254 || sk->s2k_usage == 255)
{
sk->protect.sha1chk = (sk->s2k_usage == 254);
sk->protect.algo = _pgp_cipher_to_gnutls (cdk_stream_getc (inp));
sk->protect.s2k = cdk_calloc (1, sizeof *sk->protect.s2k);
if (!sk->protect.s2k)
return CDK_Out_Of_Core;
rc = read_s2k (inp, sk->protect.s2k);
if (rc)
return rc;
/* refer to --export-secret-subkeys in gpg(1) */
if (sk->protect.s2k->mode == CDK_S2K_GNU_EXT)
sk->protect.ivlen = 0;
else
{
sk->protect.ivlen = gnutls_cipher_get_block_size (sk->protect.algo);
if (!sk->protect.ivlen)
return CDK_Inv_Packet;
rc = stream_read (inp, sk->protect.iv, sk->protect.ivlen, &nread);
if (rc)
return rc;
if (nread != sk->protect.ivlen)
return CDK_Inv_Packet;
}
}
else
sk->protect.algo = _pgp_cipher_to_gnutls (sk->s2k_usage);
if (sk->protect.algo == GNUTLS_CIPHER_NULL)
{
sk->csum = 0;
nskey = cdk_pk_get_nskey (sk->pk->pubkey_algo);
if (!nskey)
{
gnutls_assert ();
return CDK_Inv_Algo;
}
for (i = 0; i < nskey; i++)
{
rc = read_mpi (inp, &sk->mpi[i], 1);
if (rc)
return rc;
}
sk->csum = read_16 (inp);
sk->is_protected = 0;
}
else if (sk->pk->version < 4)
{
/* The length of each multiprecision integer is stored in plaintext. */
nskey = cdk_pk_get_nskey (sk->pk->pubkey_algo);
if (!nskey)
{
gnutls_assert ();
return CDK_Inv_Algo;
}
for (i = 0; i < nskey; i++)
{
rc = read_mpi (inp, &sk->mpi[i], 1);
if (rc)
return rc;
}
sk->csum = read_16 (inp);
sk->is_protected = 1;
}
else
{
/* We need to read the rest of the packet because we do not
have any information how long the encrypted mpi's are */
p2 = cdk_stream_tell (inp);
p2 -= p1;
sk->enclen = pktlen - p2;
if (sk->enclen < 2)
return CDK_Inv_Packet; /* at least 16 bits for the checksum! */
sk->encdata = cdk_calloc (1, sk->enclen + 1);
if (!sk->encdata)
return CDK_Out_Of_Core;
if (stream_read (inp, sk->encdata, sk->enclen, &nread))
return CDK_Inv_Packet;
/* Handle the GNU S2K extensions we know (just gnu-dummy right now): */
if (sk->protect.s2k->mode == CDK_S2K_GNU_EXT)
{
unsigned char gnumode;
if ((sk->enclen < strlen ("GNU") + 1) ||
(0 != memcmp ("GNU", sk->encdata, strlen ("GNU"))))
return CDK_Inv_Packet;
gnumode = sk->encdata[strlen ("GNU")];
/* we only handle gnu-dummy (mode 1).
mode 2 should refer to external smart cards.
*/
if (gnumode != 1)
return CDK_Inv_Packet;
/* gnu-dummy should have no more data */
if (sk->enclen != strlen ("GNU") + 1)
return CDK_Inv_Packet;
}
nskey = cdk_pk_get_nskey (sk->pk->pubkey_algo);
if (!nskey)
{
gnutls_assert ();
return CDK_Inv_Algo;
}
/* We mark each MPI entry with NULL to indicate a protected key. */
for (i = 0; i < nskey; i++)
sk->mpi[i] = NULL;
sk->is_protected = 1;
}
sk->is_primary = 1;
_cdk_copy_pk_to_sk (sk->pk, sk);
return 0;
}
|
↓
|
print_altname
|
31
|
98
|
191
|
x509/output.c
|
static void
print_altname (gnutls_buffer_st * str, const char *prefix, int altname_type,
cert_type_t cert)
{
unsigned int altname_idx;
char str_ip[64];
char *p;
for (altname_idx = 0;; altname_idx++)
{
char *buffer = NULL;
size_t size = 0;
int err;
if (altname_type == TYPE_CRT_SAN)
err =
gnutls_x509_crt_get_subject_alt_name (cert.crt, altname_idx, buffer,
&size, NULL);
else if (altname_type == TYPE_CRQ_SAN)
err =
gnutls_x509_crq_get_subject_alt_name (cert.crq, altname_idx, buffer,
&size, NULL, NULL);
else if (altname_type == TYPE_CRT_IAN)
err =
gnutls_x509_crt_get_issuer_alt_name (cert.crt, altname_idx, buffer,
&size, NULL);
else
return;
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
addf (str, "error: get_subject/issuer_alt_name: %s\n",
gnutls_strerror (err));
return;
}
buffer = gnutls_malloc (size);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
return;
}
if (altname_type == TYPE_CRT_SAN)
err =
gnutls_x509_crt_get_subject_alt_name (cert.crt, altname_idx, buffer,
&size, NULL);
else if (altname_type == TYPE_CRQ_SAN)
err =
gnutls_x509_crq_get_subject_alt_name (cert.crq, altname_idx, buffer,
&size, NULL, NULL);
else if (altname_type == TYPE_CRT_IAN)
err = gnutls_x509_crt_get_issuer_alt_name (cert.crt, altname_idx,
buffer, &size, NULL);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_subject/issuer_alt_name2: %s\n",
gnutls_strerror (err));
return;
}
if ((err == GNUTLS_SAN_DNSNAME
|| err == GNUTLS_SAN_RFC822NAME
|| err == GNUTLS_SAN_URI) && strlen (buffer) != size)
{
adds (str, _("warning: altname contains an embedded NUL, "
"replacing with '!'\n"));
while (strlen (buffer) < size)
buffer[strlen (buffer)] = '!';
}
switch (err)
{
case GNUTLS_SAN_DNSNAME:
addf (str, "%s\t\t\tDNSname: %.*s\n", prefix, (int) size, buffer);
break;
case GNUTLS_SAN_RFC822NAME:
addf (str, "%s\t\t\tRFC822name: %.*s\n", prefix, (int) size,
buffer);
break;
case GNUTLS_SAN_URI:
addf (str, "%s\t\t\tURI: %.*s\n", prefix, (int) size, buffer);
break;
case GNUTLS_SAN_IPADDRESS:
p = ip_to_string (buffer, size, str_ip, sizeof (str_ip));
if (p == NULL)
p = ERROR_STR;
addf (str, "%s\t\t\tIPAddress: %s\n", prefix, p);
break;
case GNUTLS_SAN_DN:
addf (str, "%s\t\t\tdirectoryName: %.*s\n", prefix,
(int) size, buffer);
break;
case GNUTLS_SAN_OTHERNAME:
{
char *oid = NULL;
size_t oidsize;
oidsize = 0;
if (altname_type == TYPE_CRT_SAN)
err = gnutls_x509_crt_get_subject_alt_othername_oid
(cert.crt, altname_idx, oid, &oidsize);
else if (altname_type == TYPE_CRQ_SAN)
err = gnutls_x509_crq_get_subject_alt_othername_oid
(cert.crq, altname_idx, oid, &oidsize);
else if (altname_type == TYPE_CRT_IAN)
err = gnutls_x509_crt_get_issuer_alt_othername_oid
(cert.crt, altname_idx, oid, &oidsize);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
gnutls_free (buffer);
addf (str,
"error: get_subject/issuer_alt_othername_oid: %s\n",
gnutls_strerror (err));
return;
}
oid = gnutls_malloc (oidsize);
if (!oid)
{
gnutls_free (buffer);
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
return;
}
if (altname_type == TYPE_CRT_SAN)
err = gnutls_x509_crt_get_subject_alt_othername_oid
(cert.crt, altname_idx, oid, &oidsize);
else if (altname_type == TYPE_CRQ_SAN)
err = gnutls_x509_crq_get_subject_alt_othername_oid
(cert.crq, altname_idx, oid, &oidsize);
else if (altname_type == TYPE_CRT_IAN)
err = gnutls_x509_crt_get_issuer_alt_othername_oid
(cert.crt, altname_idx, oid, &oidsize);
if (err < 0)
{
gnutls_free (buffer);
gnutls_free (oid);
addf (str, "error: get_subject_alt_othername_oid2: %s\n",
gnutls_strerror (err));
return;
}
if (err == GNUTLS_SAN_OTHERNAME_XMPP)
{
if (strlen (buffer) != size)
{
adds (str, _("warning: altname contains an embedded NUL, "
"replacing with '!'\n"));
while (strlen (buffer) < size)
buffer[strlen (buffer)] = '!';
}
addf (str, _("%s\t\t\tXMPP Address: %.*s\n"), prefix,
(int) size, buffer);
}
else
{
addf (str, _("%s\t\t\totherName OID: %.*s\n"), prefix,
(int) oidsize, oid);
addf (str, _("%s\t\t\totherName DER: "), prefix);
_gnutls_buffer_hexprint (str, buffer, size);
addf (str, _("\n%s\t\t\totherName ASCII: "), prefix);
_gnutls_buffer_asciiprint (str, buffer, size);
addf (str, "\n");
}
gnutls_free (oid);
}
break;
default:
addf (str, "error: unknown altname\n");
break;
}
gnutls_free (buffer);
}
}
|
↓
|
print_cert
|
31
|
159
|
304
|
x509/output.c
|
static void
print_cert (gnutls_buffer_st * str, gnutls_x509_crt_t cert, int notsigned)
{
/* Version. */
{
int version = gnutls_x509_crt_get_version (cert);
if (version < 0)
addf (str, "error: get_version: %s\n", gnutls_strerror (version));
else
addf (str, _("\tVersion: %d\n"), version);
}
/* Serial. */
{
char serial[128];
size_t serial_size = sizeof (serial);
int err;
err = gnutls_x509_crt_get_serial (cert, serial, &serial_size);
if (err < 0)
addf (str, "error: get_serial: %s\n", gnutls_strerror (err));
else
{
adds (str, _("\tSerial Number (hex): "));
_gnutls_buffer_hexprint (str, serial, serial_size);
adds (str, "\n");
}
}
/* Issuer. */
if (!notsigned)
{
char *dn;
size_t dn_size = 0;
int err;
err = gnutls_x509_crt_get_issuer_dn (cert, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "error: get_issuer_dn: %s\n", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "error: malloc (%d): %s\n", (int) dn_size,
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_x509_crt_get_issuer_dn (cert, dn, &dn_size);
if (err < 0)
addf (str, "error: get_issuer_dn: %s\n",
gnutls_strerror (err));
else
addf (str, _("\tIssuer: %s\n"), dn);
gnutls_free (dn);
}
}
}
/* Validity. */
{
time_t tim;
adds (str, _("\tValidity:\n"));
tim = gnutls_x509_crt_get_activation_time (cert);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tNot Before: %s\n"), s);
}
tim = gnutls_x509_crt_get_expiration_time (cert);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
else
addf (str, _("\t\tNot After: %s\n"), s);
}
}
/* Subject. */
{
char *dn;
size_t dn_size = 0;
int err;
err = gnutls_x509_crt_get_dn (cert, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "error: get_dn: %s\n", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "error: malloc (%d): %s\n", (int) dn_size,
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_x509_crt_get_dn (cert, dn, &dn_size);
if (err < 0)
addf (str, "error: get_dn: %s\n", gnutls_strerror (err));
else
addf (str, _("\tSubject: %s\n"), dn);
gnutls_free (dn);
}
}
}
/* SubjectPublicKeyInfo. */
{
int err, pk;
unsigned int bits;
err = gnutls_x509_crt_get_pk_algorithm (cert, &bits);
if (err < 0)
addf (str, "error: get_pk_algorithm: %s\n", gnutls_strerror (err));
else
{
gnutls_pubkey_t pubkey;
const char *name = gnutls_pk_algorithm_get_name (err);
if (name == NULL)
name = _("unknown");
pk = err;
addf (str, _("\tSubject Public Key Algorithm: %s\n"), name);
addf (str, _("\tCertificate Security Level: %s (%d bits)\n"),
gnutls_sec_param_get_name (gnutls_pk_bits_to_sec_param
(err, bits)), bits);
#ifdef ENABLE_PKI
err = gnutls_pubkey_init(&pubkey);
if (err < 0)
{
addf (str, "error: gnutls_pubkey_init: %s\n", gnutls_strerror (err));
return;
}
err = gnutls_pubkey_import_x509(pubkey, cert, 0);
if (err < 0)
{
addf (str, "error: gnutls_pubkey_import_x509: %s\n", gnutls_strerror (err));
return;
}
switch (pk)
{
case GNUTLS_PK_RSA:
{
gnutls_datum_t m, e;
err = gnutls_pubkey_get_pk_rsa_raw (pubkey, &m, &e);
if (err < 0)
addf (str, "error: get_pk_rsa_raw: %s\n",
gnutls_strerror (err));
else
{
addf (str, _("\t\tModulus (bits %d):\n"), bits);
_gnutls_buffer_hexdump (str, m.data, m.size, "\t\t\t");
addf (str, _("\t\tExponent (bits %d):\n"), e.size * 8);
_gnutls_buffer_hexdump (str, e.data, e.size, "\t\t\t");
gnutls_free (m.data);
gnutls_free (e.data);
}
}
break;
case GNUTLS_PK_EC:
{
gnutls_datum_t x, y;
gnutls_ecc_curve_t curve;
err = gnutls_pubkey_get_pk_ecc_raw (pubkey, &curve, &x, &y);
if (err < 0)
addf (str, "error: get_pk_ecc_raw: %s\n",
gnutls_strerror (err));
else
{
addf (str, _("\t\tCurve:\t%s\n"), gnutls_ecc_curve_get_name(curve));
addf (str, _("\t\tX:\n"));
_gnutls_buffer_hexdump (str, x.data, x.size, "\t\t\t");
adds (str, _("\t\tY:\n"));
_gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
gnutls_free (x.data);
gnutls_free (y.data);
}
}
break;
case GNUTLS_PK_DSA:
{
gnutls_datum_t p, q, g, y;
err = gnutls_pubkey_get_pk_dsa_raw (pubkey, &p, &q, &g, &y);
if (err < 0)
addf (str, "error: get_pk_dsa_raw: %s\n",
gnutls_strerror (err));
else
{
addf (str, _("\t\tPublic key (bits %d):\n"), bits);
_gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
adds (str, _("\t\tP:\n"));
_gnutls_buffer_hexdump (str, p.data, p.size, "\t\t\t");
adds (str, _("\t\tQ:\n"));
_gnutls_buffer_hexdump (str, q.data, q.size, "\t\t\t");
adds (str, _("\t\tG:\n"));
_gnutls_buffer_hexdump (str, g.data, g.size, "\t\t\t");
gnutls_free (p.data);
gnutls_free (q.data);
gnutls_free (g.data);
gnutls_free (y.data);
}
}
break;
default:
break;
}
gnutls_pubkey_deinit(pubkey);
#endif
}
}
print_unique_ids (str, cert);
/* Extensions. */
if (gnutls_x509_crt_get_version (cert) >= 3)
{
cert_type_t ccert;
ccert.crt = cert;
print_extensions (str, "", TYPE_CRT, ccert);
}
/* Signature. */
if (!notsigned)
{
int err;
size_t size = 0;
char *buffer = NULL;
err = gnutls_x509_crt_get_signature_algorithm (cert);
if (err < 0)
addf (str, "error: get_signature_algorithm: %s\n",
gnutls_strerror (err));
else
{
const char *name = gnutls_sign_algorithm_get_name (err);
if (name == NULL)
name = _("unknown");
addf (str, _("\tSignature Algorithm: %s\n"), name);
}
if (err == GNUTLS_SIGN_RSA_MD5 || err == GNUTLS_SIGN_RSA_MD2)
{
adds (str, _("warning: signed using a broken signature "
"algorithm that can be forged.\n"));
}
err = gnutls_x509_crt_get_signature (cert, buffer, &size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
addf (str, "error: get_signature: %s\n", gnutls_strerror (err));
return;
}
buffer = gnutls_malloc (size);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
return;
}
err = gnutls_x509_crt_get_signature (cert, buffer, &size);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_signature2: %s\n", gnutls_strerror (err));
return;
}
adds (str, _("\tSignature:\n"));
_gnutls_buffer_hexdump (str, buffer, size, "\t\t");
gnutls_free (buffer);
}
}
|
↓
|
keydb_merge_selfsig
|
30
|
86
|
117
|
opencdk/keydb.c
|
static cdk_error_t
keydb_merge_selfsig (cdk_kbnode_t key, u32 * keyid)
{
cdk_kbnode_t node, kbnode, unode;
cdk_subpkt_t s = NULL;
cdk_pkt_signature_t sig = NULL;
cdk_pkt_userid_t uid = NULL;
const byte *symalg = NULL, *hashalg = NULL, *compalg = NULL;
size_t nsymalg = 0, nhashalg = 0, ncompalg = 0, n = 0;
size_t key_expire = 0;
if (!key)
{
gnutls_assert ();
return CDK_Inv_Value;
}
for (node = key; node; node = node->next)
{
if (!is_selfsig (node, keyid))
continue;
unode = cdk_kbnode_find_prev (key, node, CDK_PKT_USER_ID);
if (!unode)
{
gnutls_assert ();
return CDK_Error_No_Key;
}
uid = unode->pkt->pkt.user_id;
sig = node->pkt->pkt.signature;
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_PRIMARY_UID);
if (s)
uid->is_primary = 1;
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_FEATURES);
if (s && s->size == 1 && s->d[0] & 0x01)
uid->mdc_feature = 1;
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_KEY_EXPIRE);
if (s && s->size == 4)
key_expire = _cdk_buftou32 (s->d);
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_PREFS_SYM);
if (s)
{
symalg = s->d;
nsymalg = s->size;
n += s->size + 1;
}
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_PREFS_HASH);
if (s)
{
hashalg = s->d;
nhashalg = s->size;
n += s->size + 1;
}
s = cdk_subpkt_find (sig->hashed, CDK_SIGSUBPKT_PREFS_ZIP);
if (s)
{
compalg = s->d;
ncompalg = s->size;
n += s->size + 1;
}
if (uid->prefs != NULL)
cdk_free (uid->prefs);
if (!n || !hashalg || !compalg || !symalg)
uid->prefs = NULL;
else
{
uid->prefs = cdk_calloc (1, sizeof (*uid->prefs) * (n + 1));
if (!uid->prefs)
{
gnutls_assert ();
return CDK_Out_Of_Core;
}
n = 0;
for (; nsymalg; nsymalg--, n++)
{
uid->prefs[n].type = CDK_PREFTYPE_SYM;
uid->prefs[n].value = *symalg++;
}
for (; nhashalg; nhashalg--, n++)
{
uid->prefs[n].type = CDK_PREFTYPE_HASH;
uid->prefs[n].value = *hashalg++;
}
for (; ncompalg; ncompalg--, n++)
{
uid->prefs[n].type = CDK_PREFTYPE_ZIP;
uid->prefs[n].value = *compalg++;
}
uid->prefs[n].type = CDK_PREFTYPE_NONE; /* end of list marker */
uid->prefs[n].value = 0;
uid->prefs_size = n;
}
}
/* Now we add the extracted information to the primary key. */
kbnode = cdk_kbnode_find (key, CDK_PKT_PUBLIC_KEY);
if (kbnode)
{
cdk_pkt_pubkey_t pk = kbnode->pkt->pkt.public_key;
if (uid && uid->prefs && n)
{
if (pk->prefs != NULL)
cdk_free (pk->prefs);
pk->prefs = _cdk_copy_prefs (uid->prefs);
pk->prefs_size = n;
}
if (key_expire)
{
pk->expiredate = pk->timestamp + key_expire;
pk->has_expired = pk->expiredate > (u32) gnutls_time (NULL) ? 0 : 1;
}
pk->is_invalid = 0;
}
return 0;
}
|
↓
|
cdk_keydb_get_keyblock
|
30
|
74
|
133
|
opencdk/keydb.c
|
cdk_error_t
cdk_keydb_get_keyblock (cdk_stream_t inp, cdk_kbnode_t * r_knode)
{
cdk_packet_t pkt;
cdk_kbnode_t knode, node;
cdk_desig_revoker_t revkeys;
cdk_error_t rc;
u32 keyid[2], main_keyid[2];
off_t old_off;
int key_seen, got_key;
if (!inp || !r_knode)
{
gnutls_assert ();
return CDK_Inv_Value;
}
/* Reset all values. */
keyid[0] = keyid[1] = 0;
main_keyid[0] = main_keyid[1] = 0;
revkeys = NULL;
knode = NULL;
key_seen = got_key = 0;
*r_knode = NULL;
rc = CDK_EOF;
while (!cdk_stream_eof (inp))
{
cdk_pkt_new (&pkt);
old_off = cdk_stream_tell (inp);
rc = cdk_pkt_read (inp, pkt);
if (rc)
{
cdk_pkt_release (pkt);
if (rc == CDK_EOF)
break;
else
{ /* Release all packets we reached so far. */
_cdk_log_debug ("keydb_get_keyblock: error %d\n", rc);
cdk_kbnode_release (knode);
gnutls_assert ();
return rc;
}
}
if (pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY ||
pkt->pkttype == CDK_PKT_SECRET_KEY ||
pkt->pkttype == CDK_PKT_SECRET_SUBKEY)
{
if (key_seen && (pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
pkt->pkttype == CDK_PKT_SECRET_KEY))
{
/* The next key starts here so set the file pointer
and leave the loop. */
cdk_stream_seek (inp, old_off);
cdk_pkt_release (pkt);
break;
}
if (pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
pkt->pkttype == CDK_PKT_SECRET_KEY)
{
_cdk_pkt_get_keyid (pkt, main_keyid);
key_seen = 1;
}
else if (pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY ||
pkt->pkttype == CDK_PKT_SECRET_SUBKEY)
{
if (pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY)
{
pkt->pkt.public_key->main_keyid[0] = main_keyid[0];
pkt->pkt.public_key->main_keyid[1] = main_keyid[1];
}
else
{
pkt->pkt.secret_key->main_keyid[0] = main_keyid[0];
pkt->pkt.secret_key->main_keyid[1] = main_keyid[1];
}
}
/* We save this for the signature */
_cdk_pkt_get_keyid (pkt, keyid);
got_key = 1;
}
else if (pkt->pkttype == CDK_PKT_USER_ID)
;
else if (pkt->pkttype == CDK_PKT_SIGNATURE)
{
cdk_subpkt_t s;
pkt->pkt.signature->key[0] = keyid[0];
pkt->pkt.signature->key[1] = keyid[1];
if (pkt->pkt.signature->sig_class == 0x1F &&
pkt->pkt.signature->revkeys)
revkeys = pkt->pkt.signature->revkeys;
s =
cdk_subpkt_find (pkt->pkt.signature->hashed,
CDK_SIGSUBPKT_KEY_FLAGS);
if (s)
{
unsigned int key_usage = key_usage_to_cdk_usage (s->d[0]);
add_key_usage (knode, pkt->pkt.signature->key, key_usage);
}
}
node = cdk_kbnode_new (pkt);
if (!knode)
knode = node;
else
_cdk_kbnode_add (knode, node);
}
if (got_key)
{
keydb_merge_selfsig (knode, main_keyid);
rc = keydb_parse_allsigs (knode, NULL, 0);
if (revkeys)
{
node = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (node)
node->pkt->pkt.public_key->revkeys = revkeys;
}
}
else
cdk_kbnode_release (knode);
*r_knode = got_key ? knode : NULL;
/* It is possible that we are in an EOF condition after we
successfully read a keyblock. For example if the requested
key is the last in the file. */
if (rc == CDK_EOF && got_key)
rc = 0;
return rc;
}
|
↓
|
_gnutls_parse_general_name
|
30
|
100
|
185
|
x509/x509.c
|
int
_gnutls_parse_general_name (ASN1_TYPE src, const char *src_name,
int seq, void *name, size_t * name_size,
unsigned int *ret_type, int othername_oid)
{
int len;
char nptr[ASN1_MAX_NAME_SIZE];
int result;
opaque choice_type[128];
gnutls_x509_subject_alt_name_t type;
seq++; /* 0->1, 1->2 etc */
if (src_name[0] != 0)
snprintf (nptr, sizeof (nptr), "%s.?%u", src_name, seq);
else
snprintf (nptr, sizeof (nptr), "?%u", seq);
len = sizeof (choice_type);
result = asn1_read_value (src, nptr, choice_type, &len);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
type = _gnutls_x509_san_find_type (choice_type);
if (type == (gnutls_x509_subject_alt_name_t) - 1)
{
gnutls_assert ();
return GNUTLS_E_X509_UNKNOWN_SAN;
}
if (ret_type)
*ret_type = type;
if (type == GNUTLS_SAN_OTHERNAME)
{
if (othername_oid)
_gnutls_str_cat (nptr, sizeof (nptr), ".otherName.type-id");
else
_gnutls_str_cat (nptr, sizeof (nptr), ".otherName.value");
len = *name_size;
result = asn1_read_value (src, nptr, name, &len);
*name_size = len;
if (result == ASN1_MEM_ERROR)
return GNUTLS_E_SHORT_MEMORY_BUFFER;
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
if (othername_oid)
{
if (len > strlen (XMPP_OID) && strcmp (name, XMPP_OID) == 0)
type = GNUTLS_SAN_OTHERNAME_XMPP;
}
else
{
char oid[42];
if (src_name[0] != 0)
snprintf (nptr, sizeof (nptr), "%s.?%u.otherName.type-id",
src_name, seq);
else
snprintf (nptr, sizeof (nptr), "?%u.otherName.type-id", seq);
len = sizeof (oid);
result = asn1_read_value (src, nptr, oid, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
if (len > strlen (XMPP_OID) && strcmp (oid, XMPP_OID) == 0)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
size_t orig_name_size = *name_size;
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.UTF8String", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, name, *name_size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
len = *name_size;
result = asn1_read_value (c2, "", name, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
*name_size = len + 1;
return _gnutls_asn2err (result);
}
asn1_delete_structure (&c2);
if (len + 1 > orig_name_size)
{
gnutls_assert ();
*name_size = len + 1;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
*name_size = len;
/* null terminate it */
((char *) name)[*name_size] = 0;
}
}
}
else if (type == GNUTLS_SAN_DN)
{
_gnutls_str_cat (nptr, sizeof (nptr), ".directoryName");
result = _gnutls_x509_parse_dn (src, nptr, name, name_size);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
else if (othername_oid)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
else
{
size_t orig_name_size = *name_size;
_gnutls_str_cat (nptr, sizeof (nptr), ".");
_gnutls_str_cat (nptr, sizeof (nptr), choice_type);
len = *name_size;
result = asn1_read_value (src, nptr, name, &len);
*name_size = len;
if (result == ASN1_MEM_ERROR)
{
if (is_type_printable (type))
(*name_size)++;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
if (is_type_printable (type))
{
if (len + 1 > orig_name_size)
{
gnutls_assert ();
(*name_size)++;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
/* null terminate it */
((char *) name)[*name_size] = 0;
}
}
return type;
}
|
↓
|
_gnutls_recv_in_buffers
|
29
|
99
|
217
|
gnutls_record.c
|
ssize_t
_gnutls_recv_in_buffers (gnutls_session_t session, content_type_t type,
gnutls_handshake_description_t htype)
{
uint64 *packet_sequence;
uint8_t *ciphertext;
mbuffer_st* bufel = NULL, *decrypted = NULL;
int ret;
int empty_packet = 0;
record_parameters_st *record_params;
record_state_st *record_state;
struct tls_record_st record;
begin:
if (empty_packet > MAX_EMPTY_PACKETS_SEQUENCE)
{
gnutls_assert ();
return GNUTLS_E_TOO_MANY_EMPTY_PACKETS;
}
memset(&record, 0, sizeof(record));
if (session->internals.read_eof != 0)
{
/* if we have already read an EOF
*/
return 0;
}
else if (session_is_valid (session) != 0
|| session->internals.may_not_read != 0)
return gnutls_assert_val(GNUTLS_E_INVALID_SESSION);
/* get the record state parameters */
ret = _gnutls_epoch_get (session, EPOCH_READ_CURRENT, &record_params);
if (ret < 0)
return gnutls_assert_val (ret);
/* Safeguard against processing data with an incomplete cipher state. */
if (!record_params->initialized)
return gnutls_assert_val (GNUTLS_E_INTERNAL_ERROR);
record_state = &record_params->read;
/* receive headers */
ret = recv_headers(session, type, htype, &record);
if (ret < 0)
{
ret = gnutls_assert_val_fatal(ret);
goto recv_error;
}
if (IS_DTLS(session))
packet_sequence = &record.sequence;
else
packet_sequence = &record_state->sequence_number;
/* Read the packet data and insert it to record_recv_buffer.
*/
ret =
_gnutls_io_read_buffered (session, record.packet_size,
record.type);
if (ret != record.packet_size)
{
gnutls_assert();
goto recv_error;
}
/* ok now we are sure that we have read all the data - so
* move on !
*/
ret = _mbuffer_linearize (&session->internals.record_recv_buffer);
if (ret < 0)
return gnutls_assert_val(ret);
bufel = _mbuffer_head_get_first (&session->internals.record_recv_buffer, NULL);
if (bufel == NULL)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
/* We allocate the maximum possible to allow few compressed bytes to expand to a
* full record.
*/
decrypted = _mbuffer_alloc(MAX_RECORD_RECV_SIZE(session), MAX_RECORD_RECV_SIZE(session));
if (decrypted == NULL)
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
ciphertext = (opaque*)_mbuffer_get_udata_ptr(bufel) + record.header_size;
/* decrypt the data we got.
*/
ret =
_gnutls_decrypt (session, ciphertext, record.length,
_mbuffer_get_udata_ptr(decrypted), _mbuffer_get_udata_size(decrypted),
record.type, record_params, packet_sequence);
if (ret >= 0) _mbuffer_set_udata_size(decrypted, ret);
_mbuffer_head_remove_bytes (&session->internals.record_recv_buffer,
record.header_size + record.length);
if (ret < 0)
{
gnutls_assert();
goto sanity_check_error;
}
/* check for duplicates. We check after the message
* is processed and authenticated to avoid someone
* messing with our windows.
*/
if (IS_DTLS(session))
{
ret = _dtls_record_check(session, packet_sequence);
if (ret < 0)
{
_gnutls_audit_log(session, "Discarded duplicate message[%u]\n",
(unsigned int) _gnutls_uint64touint32 (packet_sequence));
goto sanity_check_error;
}
}
_gnutls_record_log
("REC[%p]: Decrypted Packet[%d] %s(%d) with length: %d\n", session,
(int) _gnutls_uint64touint32 (packet_sequence),
_gnutls_packet2str (record.type), record.type, (int)_mbuffer_get_udata_size(decrypted));
/* increase sequence number
*/
if (!IS_DTLS(session) && sequence_increment (session, &record_state->sequence_number) != 0)
{
session_invalidate (session);
gnutls_assert ();
ret = GNUTLS_E_RECORD_LIMIT_REACHED;
goto sanity_check_error;
}
/* (originally for) TLS 1.0 CBC protection.
* Actually this code is called if we just received
* an empty packet. An empty TLS packet is usually
* sent to protect some vulnerabilities in the CBC mode.
* In that case we go to the beginning and start reading
* the next packet.
*/
if (_mbuffer_get_udata_size(decrypted) == 0)
{
_mbuffer_xfree(&decrypted);
empty_packet++;
goto begin;
}
if (record.v2)
decrypted->htype = GNUTLS_HANDSHAKE_CLIENT_HELLO_V2;
else
decrypted->htype = -1;
ret =
record_add_to_buffers (session, &record, type, htype,
packet_sequence, decrypted);
/* bufel is now either deinitialized or buffered somewhere else */
if (ret < 0)
{
if (ret == GNUTLS_E_INT_RET_0)
{
return 0;
}
return gnutls_assert_val(ret);
}
return ret;
discard:
session->internals.dtls.packets_dropped++;
/* discard the whole received fragment. */
bufel = _mbuffer_head_pop_first(&session->internals.record_recv_buffer);
_mbuffer_xfree(&bufel);
return gnutls_assert_val(GNUTLS_E_AGAIN);
sanity_check_error:
if (IS_DTLS(session))
{
session->internals.dtls.packets_dropped++;
_gnutls_audit_log(session, "Discarded message[%u] due to invalid decryption\n",
(unsigned int)_gnutls_uint64touint32 (packet_sequence));
ret = gnutls_assert_val(GNUTLS_E_AGAIN);
goto cleanup;
}
session_unresumable (session);
session_invalidate (session);
cleanup:
_mbuffer_xfree(&decrypted);
return ret;
recv_error:
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
return ret;
if (IS_DTLS(session))
{
goto discard;
}
session_invalidate (session);
if (type == GNUTLS_ALERT) /* we were expecting close notify */
{
gnutls_assert ();
return 0;
}
session_unresumable (session);
if (ret == 0)
return GNUTLS_E_PREMATURE_TERMINATION;
else
return ret;
}
|
↓
|
gnutls_ocsp_resp_get_single
|
29
|
90
|
178
|
x509/ocsp.c
|
int
gnutls_ocsp_resp_get_single (gnutls_ocsp_resp_t resp,
unsigned indx,
gnutls_digest_algorithm_t *digest,
gnutls_datum_t *issuer_name_hash,
gnutls_datum_t *issuer_key_hash,
gnutls_datum_t *serial_number,
int *cert_status,
time_t *this_update,
time_t *next_update,
time_t *revocation_time,
int *revocation_reason)
{
gnutls_datum_t sa;
char name[ASN1_MAX_NAME_SIZE];
int ret;
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.certID.hashAlgorithm.algorithm",
indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name, &sa, 0);
if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
else if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_x509_oid2digest_algorithm (sa.data);
_gnutls_free_datum (&sa);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (digest)
*digest = ret;
if (issuer_name_hash)
{
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.certID.issuerNameHash",
indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name,
issuer_name_hash, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
return ret;
}
}
if (issuer_key_hash)
{
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.certID.issuerKeyHash",
indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name,
issuer_key_hash, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
if (issuer_name_hash)
gnutls_free (issuer_name_hash->data);
return ret;
}
}
if (serial_number)
{
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.certID.serialNumber",
indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name,
serial_number, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
if (issuer_name_hash)
gnutls_free (issuer_name_hash->data);
if (issuer_key_hash)
gnutls_free (issuer_key_hash->data);
return ret;
}
}
if (cert_status)
{
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.certStatus",
indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name, &sa, 0);
if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
else if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (sa.size == 5 && memcmp (sa.data, "good", sa.size) == 0)
*cert_status = GNUTLS_OCSP_CERT_GOOD;
else if (sa.size == 8 && memcmp (sa.data, "revoked", sa.size) == 0)
*cert_status = GNUTLS_OCSP_CERT_REVOKED;
else if (sa.size == 8 && memcmp (sa.data, "unknown", sa.size) == 0)
*cert_status = GNUTLS_OCSP_CERT_UNKNOWN;
else
{
gnutls_assert ();
gnutls_free (sa.data);
return GNUTLS_E_ASN1_DER_ERROR;
}
gnutls_free (sa.data);
}
if (this_update)
{
char ttime[MAX_TIME];
int len;
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.thisUpdate",
indx + 1);
len = sizeof (ttime) - 1;
ret = asn1_read_value (resp->basicresp, name, ttime, &len);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
*this_update = (time_t) (-1);
}
else
*this_update = _gnutls_x509_generalTime2gtime (ttime);
}
if (next_update)
{
char ttime[MAX_TIME];
int len;
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.nextUpdate",
indx + 1);
len = sizeof (ttime) - 1;
ret = asn1_read_value (resp->basicresp, name, ttime, &len);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
*next_update = (time_t) (-1);
}
else
*next_update = _gnutls_x509_generalTime2gtime (ttime);
}
if (revocation_time)
{
char ttime[MAX_TIME];
int len;
snprintf (name, sizeof (name),
"tbsResponseData.responses.?%u.certStatus."
"revoked.revocationTime",
indx + 1);
len = sizeof (ttime) - 1;
ret = asn1_read_value (resp->basicresp, name, ttime, &len);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
*revocation_time = (time_t) (-1);
}
else
*revocation_time = _gnutls_x509_generalTime2gtime (ttime);
}
/* revocation_reason */
return GNUTLS_E_SUCCESS;
}
|
↓
|
literal_decode
|
28
|
67
|
103
|
opencdk/literal.c
|
static cdk_error_t
literal_decode (void *data, FILE * in, FILE * out)
{
literal_filter_t *pfx = data;
cdk_stream_t si, so;
cdk_packet_t pkt;
cdk_pkt_literal_t pt;
byte buf[BUFSIZE];
ssize_t nread;
int bufsize;
cdk_error_t rc;
_cdk_log_debug ("literal filter: decode\n");
if (!pfx || !in || !out)
return CDK_Inv_Value;
rc = _cdk_stream_fpopen (in, STREAMCTL_READ, &si);
if (rc)
return rc;
cdk_pkt_new (&pkt);
rc = cdk_pkt_read (si, pkt);
if (rc || pkt->pkttype != CDK_PKT_LITERAL)
{
cdk_pkt_release (pkt);
cdk_stream_close (si);
return !rc ? CDK_Inv_Packet : rc;
}
rc = _cdk_stream_fpopen (out, STREAMCTL_WRITE, &so);
if (rc)
{
cdk_pkt_release (pkt);
cdk_stream_close (si);
return rc;
}
pt = pkt->pkt.literal;
pfx->mode = pt->mode;
if (pfx->filename && pt->namelen > 0)
{
/* The name in the literal packet is more authorative. */
cdk_free (pfx->filename);
pfx->filename = dup_trim_filename (pt->name);
}
else if (!pfx->filename && pt->namelen > 0)
pfx->filename = dup_trim_filename (pt->name);
else if (!pt->namelen && !pfx->filename && pfx->orig_filename)
{
/* In this case, we need to derrive the output file name
from the original name and cut off the OpenPGP extension.
If this is not possible, we return an error. */
if (!stristr (pfx->orig_filename, ".gpg") &&
!stristr (pfx->orig_filename, ".pgp") &&
!stristr (pfx->orig_filename, ".asc"))
{
cdk_pkt_release (pkt);
cdk_stream_close (si);
cdk_stream_close (so);
_cdk_log_debug
("literal filter: no file name and no PGP extension\n");
return CDK_Inv_Mode;
}
_cdk_log_debug ("literal filter: derrive file name from original\n");
pfx->filename = dup_trim_filename (pfx->orig_filename);
pfx->filename[strlen (pfx->filename) - 4] = '\0';
}
while (!feof (in))
{
_cdk_log_debug ("literal_decode: part on %d size %lu\n",
(int) pfx->blkmode.on, pfx->blkmode.size);
if (pfx->blkmode.on)
bufsize = pfx->blkmode.size;
else
bufsize = pt->len < DIM (buf) ? pt->len : DIM (buf);
nread = cdk_stream_read (pt->buf, buf, bufsize);
if (nread == EOF)
{
rc = CDK_File_Error;
break;
}
if (pfx->md_initialized)
_gnutls_hash (&pfx->md, buf, nread);
cdk_stream_write (so, buf, nread);
pt->len -= nread;
if (pfx->blkmode.on)
{
pfx->blkmode.size = _cdk_pkt_read_len (in, &pfx->blkmode.on);
if ((ssize_t) pfx->blkmode.size == EOF)
return CDK_Inv_Packet;
}
if (pt->len <= 0 && !pfx->blkmode.on)
break;
}
cdk_stream_close (si);
cdk_stream_close (so);
cdk_pkt_release (pkt);
return rc;
}
|
↓
|
_gnutls_set_keys
|
27
|
89
|
236
|
gnutls_constate.c
|
static int
_gnutls_set_keys (gnutls_session_t session, record_parameters_st * params,
int hash_size, int IV_size, int key_size, int export_flag)
{
/* FIXME: This function is too long
*/
opaque rnd[2 * GNUTLS_RANDOM_SIZE];
opaque rrnd[2 * GNUTLS_RANDOM_SIZE];
int pos, ret;
int block_size;
char buf[65];
/* avoid using malloc */
opaque key_block[2 * MAX_HASH_SIZE + 2 * MAX_CIPHER_KEY_SIZE +
2 * MAX_CIPHER_BLOCK_SIZE];
record_state_st *client_write, *server_write;
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
client_write = ¶ms->write;
server_write = ¶ms->read;
}
else
{
client_write = ¶ms->read;
server_write = ¶ms->write;
}
block_size = 2 * hash_size + 2 * key_size;
if (export_flag == 0)
block_size += 2 * IV_size;
memcpy (rnd, session->security_parameters.server_random,
GNUTLS_RANDOM_SIZE);
memcpy (&rnd[GNUTLS_RANDOM_SIZE],
session->security_parameters.client_random, GNUTLS_RANDOM_SIZE);
memcpy (rrnd, session->security_parameters.client_random,
GNUTLS_RANDOM_SIZE);
memcpy (&rrnd[GNUTLS_RANDOM_SIZE],
session->security_parameters.server_random, GNUTLS_RANDOM_SIZE);
if (session->security_parameters.version == GNUTLS_SSL3)
{ /* SSL 3 */
ret =
_gnutls_ssl3_generate_random
(session->security_parameters.master_secret, GNUTLS_MASTER_SIZE, rnd,
2 * GNUTLS_RANDOM_SIZE, block_size, key_block);
}
else
{ /* TLS 1.0 */
ret =
_gnutls_PRF (session, session->security_parameters.master_secret,
GNUTLS_MASTER_SIZE, keyexp, keyexp_length,
rnd, 2 * GNUTLS_RANDOM_SIZE, block_size, key_block);
}
if (ret < 0)
return gnutls_assert_val (ret);
_gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size,
_gnutls_bin2hex (key_block, block_size, buf,
sizeof (buf), NULL));
pos = 0;
if (hash_size > 0)
{
if (_gnutls_sset_datum
(&client_write->mac_secret, &key_block[pos], hash_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
pos += hash_size;
if (_gnutls_sset_datum
(&server_write->mac_secret, &key_block[pos], hash_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
pos += hash_size;
}
if (key_size > 0)
{
opaque key1[EXPORT_FINAL_KEY_SIZE];
opaque key2[EXPORT_FINAL_KEY_SIZE];
opaque *client_write_key, *server_write_key;
int client_write_key_size, server_write_key_size;
if (export_flag == 0)
{
client_write_key = &key_block[pos];
client_write_key_size = key_size;
pos += key_size;
server_write_key = &key_block[pos];
server_write_key_size = key_size;
pos += key_size;
}
else
{ /* export */
client_write_key = key1;
server_write_key = key2;
/* generate the final keys */
if (session->security_parameters.version == GNUTLS_SSL3)
{ /* SSL 3 */
ret =
_gnutls_ssl3_hash_md5 (&key_block[pos],
key_size, rrnd,
2 * GNUTLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE,
client_write_key);
}
else
{ /* TLS 1.0 */
ret =
_gnutls_PRF (session, &key_block[pos], key_size,
cliwrite, cliwrite_length,
rrnd,
2 * GNUTLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE, client_write_key);
}
if (ret < 0)
return gnutls_assert_val (ret);
client_write_key_size = EXPORT_FINAL_KEY_SIZE;
pos += key_size;
if (session->security_parameters.version == GNUTLS_SSL3)
{ /* SSL 3 */
ret =
_gnutls_ssl3_hash_md5 (&key_block[pos], key_size,
rnd, 2 * GNUTLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE,
server_write_key);
}
else
{ /* TLS 1.0 */
ret =
_gnutls_PRF (session, &key_block[pos], key_size,
servwrite, servwrite_length,
rrnd, 2 * GNUTLS_RANDOM_SIZE,
EXPORT_FINAL_KEY_SIZE, server_write_key);
}
if (ret < 0)
return gnutls_assert_val (ret);
server_write_key_size = EXPORT_FINAL_KEY_SIZE;
pos += key_size;
}
if (_gnutls_sset_datum
(&client_write->key, client_write_key, client_write_key_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
_gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n",
client_write_key_size,
_gnutls_bin2hex (client_write_key,
client_write_key_size, buf,
sizeof (buf), NULL));
if (_gnutls_sset_datum
(&server_write->key, server_write_key, server_write_key_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
_gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n",
server_write_key_size,
_gnutls_bin2hex (server_write_key,
server_write_key_size, buf,
sizeof (buf), NULL));
}
/* IV generation in export and non export ciphers.
*/
if (IV_size > 0 && export_flag == 0)
{
if (_gnutls_sset_datum
(&client_write->IV, &key_block[pos], IV_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
pos += IV_size;
if (_gnutls_sset_datum
(&server_write->IV, &key_block[pos], IV_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
pos += IV_size;
}
else if (IV_size > 0 && export_flag != 0)
{
opaque iv_block[MAX_CIPHER_BLOCK_SIZE * 2];
if (session->security_parameters.version == GNUTLS_SSL3)
{ /* SSL 3 */
ret = _gnutls_ssl3_hash_md5 ("", 0,
rrnd, GNUTLS_RANDOM_SIZE * 2,
IV_size, iv_block);
if (ret < 0)
return gnutls_assert_val (ret);
ret = _gnutls_ssl3_hash_md5 ("", 0, rnd,
GNUTLS_RANDOM_SIZE * 2,
IV_size, &iv_block[IV_size]);
}
else
{ /* TLS 1.0 */
ret = _gnutls_PRF (session, "", 0,
ivblock, ivblock_length, rrnd,
2 * GNUTLS_RANDOM_SIZE, IV_size * 2, iv_block);
}
if (ret < 0)
return gnutls_assert_val (ret);
if (_gnutls_sset_datum (&client_write->IV, iv_block, IV_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
if (_gnutls_sset_datum
(&server_write->IV, &iv_block[IV_size], IV_size) < 0)
return gnutls_assert_val (GNUTLS_E_MEMORY_ERROR);
}
return 0;
}
|
↓
|
cdk_pkt_read
|
26
|
105
|
166
|
opencdk/read-packet.c
|
cdk_error_t
cdk_pkt_read (cdk_stream_t inp, cdk_packet_t pkt)
{
int ctb, is_newctb;
int pkttype;
size_t pktlen = 0, pktsize = 0, is_partial = 0;
cdk_error_t rc;
if (!inp || !pkt)
return CDK_Inv_Value;
ctb = cdk_stream_getc (inp);
if (cdk_stream_eof (inp) || ctb == EOF)
return CDK_EOF;
else if (!ctb)
return CDK_Inv_Packet;
pktsize++;
if (!(ctb & 0x80))
{
_cdk_log_info ("cdk_pkt_read: no openpgp data found. "
"(ctb=%02X; fpos=%02X)\n", (int) ctb,
(int) cdk_stream_tell (inp));
return CDK_Inv_Packet;
}
if (ctb & 0x40) /* RFC2440 packet format. */
{
pkttype = ctb & 0x3f;
is_newctb = 1;
}
else /* the old RFC1991 packet format. */
{
pkttype = ctb & 0x3f;
pkttype >>= 2;
is_newctb = 0;
}
if (pkttype > 63)
{
_cdk_log_info ("cdk_pkt_read: unknown type %d\n", pkttype);
return CDK_Inv_Packet;
}
if (is_newctb)
read_new_length (inp, &pktlen, &pktsize, &is_partial);
else
read_old_length (inp, ctb, &pktlen, &pktsize);
pkt->pkttype = pkttype;
pkt->pktlen = pktlen;
pkt->pktsize = pktsize + pktlen;
pkt->old_ctb = is_newctb ? 0 : 1;
rc = 0;
switch (pkt->pkttype)
{
case CDK_PKT_ATTRIBUTE:
#define NAME_SIZE (pkt->pktlen + 16 + 1)
pkt->pkt.user_id = cdk_calloc (1, sizeof *pkt->pkt.user_id
+ NAME_SIZE);
if (!pkt->pkt.user_id)
return CDK_Out_Of_Core;
pkt->pkt.user_id->name =
(char *) pkt->pkt.user_id + sizeof (*pkt->pkt.user_id);
rc = read_attribute (inp, pktlen, pkt->pkt.user_id, NAME_SIZE);
pkt->pkttype = CDK_PKT_ATTRIBUTE;
break;
case CDK_PKT_USER_ID:
pkt->pkt.user_id = cdk_calloc (1, sizeof *pkt->pkt.user_id
+ pkt->pktlen + 1);
if (!pkt->pkt.user_id)
return CDK_Out_Of_Core;
pkt->pkt.user_id->name =
(char *) pkt->pkt.user_id + sizeof (*pkt->pkt.user_id);
rc = read_user_id (inp, pktlen, pkt->pkt.user_id);
break;
case CDK_PKT_PUBLIC_KEY:
pkt->pkt.public_key = cdk_calloc (1, sizeof *pkt->pkt.public_key);
if (!pkt->pkt.public_key)
return CDK_Out_Of_Core;
rc = read_public_key (inp, pktlen, pkt->pkt.public_key);
break;
case CDK_PKT_PUBLIC_SUBKEY:
pkt->pkt.public_key = cdk_calloc (1, sizeof *pkt->pkt.public_key);
if (!pkt->pkt.public_key)
return CDK_Out_Of_Core;
rc = read_public_subkey (inp, pktlen, pkt->pkt.public_key);
break;
case CDK_PKT_SECRET_KEY:
pkt->pkt.secret_key = cdk_calloc (1, sizeof *pkt->pkt.secret_key);
if (!pkt->pkt.secret_key)
return CDK_Out_Of_Core;
pkt->pkt.secret_key->pk = cdk_calloc (1,
sizeof *pkt->pkt.secret_key->pk);
if (!pkt->pkt.secret_key->pk)
return CDK_Out_Of_Core;
rc = read_secret_key (inp, pktlen, pkt->pkt.secret_key);
break;
case CDK_PKT_SECRET_SUBKEY:
pkt->pkt.secret_key = cdk_calloc (1, sizeof *pkt->pkt.secret_key);
if (!pkt->pkt.secret_key)
return CDK_Out_Of_Core;
pkt->pkt.secret_key->pk = cdk_calloc (1,
sizeof *pkt->pkt.secret_key->pk);
if (!pkt->pkt.secret_key->pk)
return CDK_Out_Of_Core;
rc = read_secret_subkey (inp, pktlen, pkt->pkt.secret_key);
break;
case CDK_PKT_LITERAL:
pkt->pkt.literal = cdk_calloc (1, sizeof *pkt->pkt.literal);
if (!pkt->pkt.literal)
return CDK_Out_Of_Core;
rc = read_literal (inp, pktlen, &pkt->pkt.literal, is_partial);
break;
case CDK_PKT_ONEPASS_SIG:
pkt->pkt.onepass_sig = cdk_calloc (1, sizeof *pkt->pkt.onepass_sig);
if (!pkt->pkt.onepass_sig)
return CDK_Out_Of_Core;
rc = read_onepass_sig (inp, pktlen, pkt->pkt.onepass_sig);
break;
case CDK_PKT_SIGNATURE:
pkt->pkt.signature = cdk_calloc (1, sizeof *pkt->pkt.signature);
if (!pkt->pkt.signature)
return CDK_Out_Of_Core;
rc = read_signature (inp, pktlen, pkt->pkt.signature);
break;
case CDK_PKT_PUBKEY_ENC:
pkt->pkt.pubkey_enc = cdk_calloc (1, sizeof *pkt->pkt.pubkey_enc);
if (!pkt->pkt.pubkey_enc)
return CDK_Out_Of_Core;
rc = read_pubkey_enc (inp, pktlen, pkt->pkt.pubkey_enc);
break;
case CDK_PKT_COMPRESSED:
pkt->pkt.compressed = cdk_calloc (1, sizeof *pkt->pkt.compressed);
if (!pkt->pkt.compressed)
return CDK_Out_Of_Core;
rc = read_compressed (inp, pktlen, pkt->pkt.compressed);
break;
case CDK_PKT_MDC:
pkt->pkt.mdc = cdk_calloc (1, sizeof *pkt->pkt.mdc);
if (!pkt->pkt.mdc)
return CDK_Out_Of_Core;
rc = read_mdc (inp, pkt->pkt.mdc);
break;
default:
/* Skip all packets we don't understand */
skip_packet (inp, pktlen);
break;
}
return rc;
}
|
↓
|
_gnutls_send_client_hello
|
26
|
85
|
206
|
gnutls_handshake.c
|
static int
_gnutls_send_client_hello (gnutls_session_t session, int again)
{
mbuffer_st *bufel = NULL;
opaque *data = NULL;
int pos = 0, type;
int datalen = 0, ret = 0;
opaque rnd[GNUTLS_RANDOM_SIZE];
gnutls_protocol_t hver;
gnutls_buffer_st extdata;
int rehandshake = 0;
uint8_t session_id_len =
session->internals.resumed_security_parameters.session_id_size;
uint8_t cookie_len;
_gnutls_buffer_init(&extdata);
/* note that rehandshake is different than resuming
*/
if (session->security_parameters.session_id_size)
rehandshake = 1;
if (again == 0)
{
if(IS_DTLS(session))
{
cookie_len = session->internals.dtls.cookie_len + 1;
}
else
{
cookie_len = 0;
}
datalen = 2 + (session_id_len + 1) + GNUTLS_RANDOM_SIZE + cookie_len;
/* 2 for version, (4 for unix time + 28 for random bytes==GNUTLS_RANDOM_SIZE)
*/
bufel = _gnutls_handshake_alloc (session, datalen, datalen+MAX_EXT_DATA_LENGTH);
if (bufel == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
data = _mbuffer_get_udata_ptr (bufel);
/* if we are resuming a session then we set the
* version number to the previously established.
*/
if (session_id_len == 0)
{
if (rehandshake) /* already negotiated version thus version_max == negotiated version */
hver = session->security_parameters.version;
else /* new handshake. just get the max */
hver = _gnutls_version_max (session);
}
else
{
/* we are resuming a session */
hver = session->internals.resumed_security_parameters.version;
}
if (hver == GNUTLS_VERSION_UNKNOWN || hver == 0)
{
gnutls_assert ();
gnutls_free (bufel);
return GNUTLS_E_INTERNAL_ERROR;
}
data[pos++] = _gnutls_version_get_major (hver);
data[pos++] = _gnutls_version_get_minor (hver);
/* Set the version we advertized as maximum
* (RSA uses it).
*/
_gnutls_set_adv_version (session, hver);
_gnutls_set_current_version (session, hver);
if (session->internals.priorities.ssl3_record_version != 0)
{
/* Advertize the SSL 3.0 record packet version in
* record packets during the handshake.
* That is to avoid confusing implementations
* that do not support TLS 1.2 and don't know
* how 3,3 version of record packets look like.
*/
if (!IS_DTLS(session))
_gnutls_record_set_default_version (session, 3, 0);
else
_gnutls_record_set_default_version (session, 254, 255);
}
/* In order to know when this session was initiated.
*/
session->security_parameters.timestamp = gnutls_time (NULL);
/* Generate random data
*/
if (!IS_DTLS (session)
|| session->internals.dtls.hsk_hello_verify_requests == 0)
{
_gnutls_tls_create_random (rnd);
_gnutls_set_client_random (session, rnd);
memcpy (&data[pos], rnd, GNUTLS_RANDOM_SIZE);
}
else
memcpy (&data[pos], session->security_parameters.client_random, GNUTLS_RANDOM_SIZE);
pos += GNUTLS_RANDOM_SIZE;
/* Copy the Session ID
*/
data[pos++] = session_id_len;
if (session_id_len > 0)
{
memcpy (&data[pos],
session->internals.resumed_security_parameters.session_id,
session_id_len);
pos += session_id_len;
}
/* Copy the DTLS cookie
*/
if (IS_DTLS(session))
{
data[pos++] = session->internals.dtls.cookie_len;
memcpy(&data[pos], &session->internals.dtls.cookie, session->internals.dtls.cookie_len);
pos += session->internals.dtls.cookie_len;
}
/* Copy the ciphersuites.
*
* If using SSLv3 Send TLS_RENEGO_PROTECTION_REQUEST SCSV for MITM
* prevention on initial negotiation (but not renegotiation; that's
* handled with the RI extension below).
*/
if (!session->internals.initial_negotiation_completed &&
session->security_parameters.entity == GNUTLS_CLIENT &&
(gnutls_protocol_get_version (session) == GNUTLS_SSL3 ||
session->internals.priorities.no_extensions != 0))
{
ret =
_gnutls_copy_ciphersuites (session, &extdata, TRUE);
_gnutls_extension_list_add (session,
GNUTLS_EXTENSION_SAFE_RENEGOTIATION);
}
else
ret = _gnutls_copy_ciphersuites (session, &extdata, FALSE);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
/* Copy the compression methods.
*/
ret = _gnutls_copy_comp_methods (session, &extdata);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
/* Generate and copy TLS extensions.
*/
if (session->internals.priorities.no_extensions == 0)
{
if (_gnutls_version_has_extensions (hver))
type = GNUTLS_EXT_ANY;
else
{
if (session->internals.initial_negotiation_completed != 0)
type = GNUTLS_EXT_MANDATORY;
else
type = GNUTLS_EXT_NONE;
}
ret = _gnutls_gen_extensions (session, &extdata, type);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
}
ret = _mbuffer_append_data (bufel, extdata.data, extdata.length);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
}
_gnutls_buffer_clear(&extdata);
return
_gnutls_send_handshake (session, bufel, GNUTLS_HANDSHAKE_CLIENT_HELLO);
cleanup:
_mbuffer_xfree(&bufel);
_gnutls_buffer_clear(&extdata);
return ret;
}
|
↓
|
parse_sig_subpackets
|
26
|
48
|
69
|
opencdk/read-packet.c
|
static cdk_error_t
parse_sig_subpackets (cdk_pkt_signature_t sig)
{
cdk_subpkt_t node;
/* Setup the standard packet entries, so we can use V4
signatures similar to V3. */
for (node = sig->unhashed; node; node = node->next)
{
if (node->type == CDK_SIGSUBPKT_ISSUER && node->size >= 8)
{
sig->keyid[0] = _cdk_buftou32 (node->d);
sig->keyid[1] = _cdk_buftou32 (node->d + 4);
}
else if (node->type == CDK_SIGSUBPKT_EXPORTABLE && node->d[0] == 0)
{
/* Sometimes this packet might be placed in the unhashed area */
sig->flags.exportable = 0;
}
}
for (node = sig->hashed; node; node = node->next)
{
if (node->type == CDK_SIGSUBPKT_SIG_CREATED && node->size >= 4)
sig->timestamp = _cdk_buftou32 (node->d);
else if (node->type == CDK_SIGSUBPKT_SIG_EXPIRE && node->size >= 4)
{
sig->expiredate = _cdk_buftou32 (node->d);
if (sig->expiredate > 0 && sig->expiredate < (u32) gnutls_time (NULL))
sig->flags.expired = 1;
}
else if (node->type == CDK_SIGSUBPKT_POLICY)
sig->flags.policy_url = 1;
else if (node->type == CDK_SIGSUBPKT_NOTATION)
sig->flags.notation = 1;
else if (node->type == CDK_SIGSUBPKT_REVOCABLE && node->d[0] == 0)
sig->flags.revocable = 0;
else if (node->type == CDK_SIGSUBPKT_EXPORTABLE && node->d[0] == 0)
sig->flags.exportable = 0;
}
if (sig->sig_class == 0x1F)
{
cdk_desig_revoker_t r, rnode;
for (node = sig->hashed; node; node = node->next)
{
if (node->type == CDK_SIGSUBPKT_REV_KEY)
{
if (node->size < 22)
continue;
rnode = cdk_calloc (1, sizeof *rnode);
if (!rnode)
return CDK_Out_Of_Core;
rnode->r_class = node->d[0];
rnode->algid = node->d[1];
memcpy (rnode->fpr, node->d + 2, KEY_FPR_LEN);
if (!sig->revkeys)
sig->revkeys = rnode;
else
{
for (r = sig->revkeys; r->next; r = r->next)
;
r->next = rnode;
}
}
}
}
return 0;
}
|
↓
|
_gnutls_x509_parse_dn
|
26
|
124
|
239
|
x509/dn.c
|
int
_gnutls_x509_parse_dn (ASN1_TYPE asn1_struct,
const char *asn1_rdn_name, char *buf,
size_t * sizeof_buf)
{
gnutls_buffer_st out_str;
int k2, k1, result;
char tmpbuffer1[ASN1_MAX_NAME_SIZE];
char tmpbuffer2[ASN1_MAX_NAME_SIZE];
char tmpbuffer3[ASN1_MAX_NAME_SIZE];
opaque value[MAX_STRING_LEN], *value2 = NULL;
char *escaped = NULL;
const char *ldap_desc;
char oid[MAX_OID_SIZE];
int len, printable;
char *string = NULL;
size_t sizeof_string, sizeof_escaped;
if (sizeof_buf == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (*sizeof_buf > 0 && buf)
buf[0] = 0;
else
*sizeof_buf = 0;
_gnutls_buffer_init (&out_str);
k1 = 0;
do
{
k1++;
/* create a string like "tbsCertList.issuer.rdnSequence.?1"
*/
if (asn1_rdn_name[0] != 0)
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", asn1_rdn_name,
k1);
else
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
break;
}
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
k2 = 0;
do
{ /* Move to the attibute type and values
*/
k2++;
if (tmpbuffer1[0] != 0)
snprintf (tmpbuffer2, sizeof (tmpbuffer2), "%s.?%u", tmpbuffer1,
k2);
else
snprintf (tmpbuffer2, sizeof (tmpbuffer2), "?%u", k2);
/* Try to read the RelativeDistinguishedName attributes.
*/
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer2, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
break;
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Read the OID
*/
_gnutls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
_gnutls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
len = sizeof (oid) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
break;
else if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Read the Value
*/
_gnutls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
_gnutls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value");
len = 0;
result = asn1_read_value (asn1_struct, tmpbuffer3, NULL, &len);
value2 = gnutls_malloc (len);
if (value2 == NULL)
{
gnutls_assert ();
result = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
result = asn1_read_value (asn1_struct, tmpbuffer3, value2, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
#define STR_APPEND(y) if ((result=_gnutls_buffer_append_str( &out_str, y)) < 0) { \
gnutls_assert(); \
goto cleanup; \
}
/* The encodings of adjoining RelativeDistinguishedNames are separated
* by a comma character (',' ASCII 44).
*/
/* Where there is a multi-valued RDN, the outputs from adjoining
* AttributeTypeAndValues are separated by a plus ('+' ASCII 43)
* character.
*/
if (k1 != 1)
{ /* the first time do not append a comma */
if (k2 != 1)
{ /* adjoining multi-value RDN */
STR_APPEND ("+");
}
else
{
STR_APPEND (",");
}
}
ldap_desc = gnutls_x509_dn_oid_name (oid, GNUTLS_X509_DN_OID_RETURN_OID);
printable = _gnutls_x509_oid_data_printable (oid);
/* leading #, hex encoded value and terminating NULL */
sizeof_escaped = 2 * len + 2;
escaped = gnutls_malloc (sizeof_escaped);
if (escaped == NULL)
{
gnutls_assert ();
result = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
sizeof_string = 2 * len + 2; /* in case it is not printable */
string = gnutls_malloc (sizeof_string);
if (string == NULL)
{
gnutls_assert ();
result = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
STR_APPEND (ldap_desc);
STR_APPEND ("=");
result = 0;
if (printable)
result =
_gnutls_x509_oid_data2string (oid,
value2, len,
string, &sizeof_string);
if (!printable || result < 0)
result =
_gnutls_x509_data2hex (value2, len, string, &sizeof_string);
if (result < 0)
{
gnutls_assert ();
_gnutls_debug_log
("Found OID: '%s' with value '%s'\n",
oid, _gnutls_bin2hex (value2, len, escaped, sizeof_escaped,
NULL));
goto cleanup;
}
STR_APPEND (str_escape (string, escaped, sizeof_escaped));
gnutls_free (string);
string = NULL;
gnutls_free (escaped);
escaped = NULL;
gnutls_free (value2);
value2 = NULL;
}
while (1);
}
while (1);
if (out_str.length >= (unsigned int) *sizeof_buf)
{
gnutls_assert ();
*sizeof_buf = out_str.length + 1;
result = GNUTLS_E_SHORT_MEMORY_BUFFER;
goto cleanup;
}
if (buf)
{
_gnutls_buffer_pop_data (&out_str, buf, sizeof_buf);
buf[*sizeof_buf] = 0;
}
else
*sizeof_buf = out_str.length;
result = 0;
cleanup:
gnutls_free (value2);
gnutls_free (string);
gnutls_free (escaped);
_gnutls_buffer_clear (&out_str);
return result;
}
|
↓
|
_gnutls_x509_oid_data2string
|
25
|
70
|
142
|
x509/common.c
|
int
_gnutls_x509_oid_data2string (const char *oid, void *value,
int value_size, char *res, size_t * res_size)
{
char str[MAX_STRING_LEN], tmpname[128];
const char *ANAME = NULL;
int CHOICE = -1, len = -1, result;
ASN1_TYPE tmpasn = ASN1_TYPE_EMPTY;
char asn1_err[ASN1_MAX_ERROR_DESCRIPTION_SIZE] = "";
if (value == NULL || value_size <= 0 || res_size == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (_gnutls_x509_oid_data_printable (oid) == 0)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
ANAME = _gnutls_x509_oid2asn_string (oid);
CHOICE = _gnutls_x509_oid_data_choice (oid);
if (ANAME == NULL)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
if ((result =
asn1_create_element (_gnutls_get_pkix (), ANAME,
&tmpasn)) != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
if ((result =
asn1_der_decoding (&tmpasn, value, value_size,
asn1_err)) != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_debug_log ("asn1_der_decoding: %s:%s\n", str, asn1_err);
asn1_delete_structure (&tmpasn);
return _gnutls_asn2err (result);
}
/* If this is a choice then we read the choice. Otherwise it
* is the value;
*/
len = sizeof (str) - 1;
if ((result = asn1_read_value (tmpasn, "", str, &len)) != ASN1_SUCCESS)
{ /* CHOICE */
gnutls_assert ();
asn1_delete_structure (&tmpasn);
return _gnutls_asn2err (result);
}
if (CHOICE == 0)
{
str[len] = 0;
/* Refuse to deal with strings containing NULs. */
if (strlen (str) != len)
return GNUTLS_E_ASN1_DER_ERROR;
if (res)
_gnutls_str_cpy (res, *res_size, str);
*res_size = len;
asn1_delete_structure (&tmpasn);
}
else
{ /* CHOICE */
int non_printable = 0, teletex = 0;
str[len] = 0;
/* Note that we do not support strings other than
* UTF-8 (thus ASCII as well).
*/
if (strcmp (str, "printableString") != 0 &&
strcmp (str, "ia5String") != 0 && strcmp (str, "utf8String") != 0)
{
non_printable = 1;
}
if (strcmp (str, "teletexString") == 0)
teletex = 1;
_gnutls_str_cpy (tmpname, sizeof (tmpname), str);
len = sizeof (str) - 1;
if ((result =
asn1_read_value (tmpasn, tmpname, str, &len)) != ASN1_SUCCESS)
{
asn1_delete_structure (&tmpasn);
return _gnutls_asn2err (result);
}
asn1_delete_structure (&tmpasn);
if (teletex != 0)
{
int ascii = 0, i;
/* HACK: if the teletex string contains only ascii
* characters then treat it as printable.
*/
for (i = 0; i < len; i++)
if (!isascii (str[i]))
ascii = 1;
if (ascii == 0)
non_printable = 0;
}
if (non_printable == 0)
{
str[len] = 0;
/* Refuse to deal with strings containing NULs. */
if (strlen (str) != len)
return GNUTLS_E_ASN1_DER_ERROR;
if (res)
_gnutls_str_cpy (res, *res_size, str);
*res_size = len;
}
else
{
result = _gnutls_x509_data2hex (str, len, res, res_size);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
}
return 0;
}
|
↓
|
register_padlock_crypto
|
25
|
67
|
183
|
accelerated/x86/aes-padlock.c
|
void
register_padlock_crypto (void)
{
int ret, phe;
if (check_via () == 0)
return;
if (check_padlock ())
{
_gnutls_debug_log ("Padlock AES accelerator was detected\n");
ret =
gnutls_crypto_single_cipher_register
(GNUTLS_CIPHER_AES_128_CBC, 80, &aes_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
/* register GCM ciphers */
ret =
gnutls_crypto_single_cipher_register
(GNUTLS_CIPHER_AES_128_GCM, 80, &aes_gcm_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
#ifdef HAVE_LIBNETTLE
ret =
gnutls_crypto_single_cipher_register (GNUTLS_CIPHER_AES_192_CBC,
80, &aes_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_cipher_register (GNUTLS_CIPHER_AES_256_CBC,
80, &aes_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_cipher_register (GNUTLS_CIPHER_AES_256_GCM,
80, &aes_gcm_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
#endif
}
#ifdef HAVE_LIBNETTLE
phe = check_phe ();
if (check_phe_partial () && phe)
{
_gnutls_debug_log ("Padlock SHA1 and SHA256 (partial) accelerator was detected\n");
if (check_phe_sha512 ())
{
_gnutls_debug_log ("Padlock SHA512 (partial) accelerator was detected\n");
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA384,
80,
&sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA512,
80,
&sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_mac_register (GNUTLS_MAC_SHA384,
80,
&hmac_sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_mac_register (GNUTLS_MAC_SHA512,
80,
&hmac_sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
}
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA1,
80, &sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA224,
80, &sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA256,
80, &sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_mac_register (GNUTLS_MAC_SHA1,
80, &hmac_sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
/* we don't register MAC_SHA224 because it is not used by TLS */
ret =
gnutls_crypto_single_mac_register (GNUTLS_MAC_SHA256,
80, &hmac_sha_padlock_nano_struct);
if (ret < 0)
{
gnutls_assert ();
}
}
else if (phe)
{
/* Original padlock PHE. Does not support incremental operations.
*/
_gnutls_debug_log ("Padlock SHA1 and SHA256 accelerator was detected\n");
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA1,
80, &sha_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_digest_register (GNUTLS_DIG_SHA256,
80, &sha_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_mac_register (GNUTLS_MAC_SHA1,
80, &hmac_sha_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
ret =
gnutls_crypto_single_mac_register (GNUTLS_MAC_SHA256,
80, &hmac_sha_padlock_struct);
if (ret < 0)
{
gnutls_assert ();
}
}
#endif
return;
}
|
↓
|
ecc_mulmod_timing
|
25
|
65
|
131
|
nettle/ecc_mulmod_timing.c
|
int
ecc_mulmod_timing (mpz_t k, ecc_point * G, ecc_point * R, mpz_t a, mpz_t modulus,
int map)
{
ecc_point *tG, *M[3];
int i, j, err;
int bit_to_read;
int mode;
if (k == NULL || G == NULL || R == NULL || modulus == NULL)
return -1;
/* alloc ram for window temps */
for (i = 0; i < 3; i++)
{
M[i] = ecc_new_point ();
if (M[i] == NULL)
{
for (j = 0; j < i; j++)
{
ecc_del_point (M[j]);
}
return -1;
}
}
/* make a copy of G incase R==G */
tG = ecc_new_point ();
if (tG == NULL)
{
err = -1;
goto done;
}
/* tG = G and convert to montgomery */
mpz_set (tG->x, G->x);
mpz_set (tG->y, G->y);
mpz_set (tG->z, G->z);
/* calc the M tab */
/* M[0] == G */
mpz_set (M[0]->x, tG->x);
mpz_set (M[0]->y, tG->y);
mpz_set (M[0]->z, tG->z);
/* M[1] == 2G */
if ((err = ecc_projective_dbl_point (tG, M[1], a, modulus)) != 0)
{
goto done;
}
/* setup sliding window */
mode = 0;
bit_to_read = mpz_size (k) * GMP_NUMB_BITS - 1;
/* perform ops */
for (;;)
{
/* grab next digit as required */
if (bit_to_read == -1)
break;
i = mpz_tstbit (k, bit_to_read--);
if (mode == 0 && i == 0)
{
/* dummy operations */
if ((err =
ecc_projective_add_point (M[0], M[1], M[2], a,
modulus)) != 0)
{
goto done;
}
if ((err =
ecc_projective_dbl_point (M[1], M[2], a, modulus)) != 0)
{
goto done;
}
continue;
}
if (mode == 0 && i == 1)
{
mode = 1;
/* dummy operations */
if ((err =
ecc_projective_add_point (M[0], M[1], M[2], a,
modulus)) != 0)
{
goto done;
}
if ((err =
ecc_projective_dbl_point (M[1], M[2], a, modulus)) != 0)
{
goto done;
}
continue;
}
if ((err =
ecc_projective_add_point (M[0], M[1], M[i ^ 1], a,
modulus)) != 0)
{
goto done;
}
if ((err = ecc_projective_dbl_point (M[i], M[i], a, modulus)) != 0)
{
goto done;
}
}
/* copy result out */
mpz_set (R->x, M[0]->x);
mpz_set (R->y, M[0]->y);
mpz_set (R->z, M[0]->z);
/* map R back from projective space */
if (map)
{
err = ecc_map (R, modulus);
}
else
{
err = 0;
}
done:
ecc_del_point (tG);
for (i = 0; i < 3; i++)
{
ecc_del_point (M[i]);
}
return err;
}
|
↓
|
ciphertext_to_compressed
|
24
|
73
|
177
|
gnutls_cipher.c
|
static int
ciphertext_to_compressed (gnutls_session_t session,
gnutls_datum_t *ciphertext,
opaque * compress_data,
int compress_size,
uint8_t type, record_parameters_st * params,
uint64* sequence)
{
uint8_t tag[MAX_HASH_SIZE];
uint8_t pad;
int length, length_to_decrypt;
uint16_t blocksize;
int ret, i, pad_failed = 0;
opaque preamble[MAX_PREAMBLE_SIZE];
int preamble_size;
int ver = gnutls_protocol_get_version (session);
int tag_size = _gnutls_auth_cipher_tag_len (¶ms->read.cipher_state);
int explicit_iv = _gnutls_version_has_explicit_iv (session->security_parameters.version);
blocksize = gnutls_cipher_get_block_size (params->cipher_algorithm);
/* actual decryption (inplace)
*/
switch (_gnutls_cipher_is_block (params->cipher_algorithm))
{
case CIPHER_STREAM:
/* The way AEAD ciphers are defined in RFC5246, it allows
* only stream ciphers.
*/
if (explicit_iv && _gnutls_auth_cipher_is_aead(¶ms->read.cipher_state))
{
uint8_t nonce[blocksize];
/* Values in AEAD are pretty fixed in TLS 1.2 for 128-bit block
*/
if (params->read.IV.data == NULL || params->read.IV.size != 4)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
if (ciphertext->size < tag_size+AEAD_EXPLICIT_DATA_SIZE)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
memcpy(nonce, params->read.IV.data, AEAD_IMPLICIT_DATA_SIZE);
memcpy(&nonce[AEAD_IMPLICIT_DATA_SIZE], ciphertext->data, AEAD_EXPLICIT_DATA_SIZE);
_gnutls_auth_cipher_setiv(¶ms->read.cipher_state, nonce, AEAD_EXPLICIT_DATA_SIZE+AEAD_IMPLICIT_DATA_SIZE);
ciphertext->data += AEAD_EXPLICIT_DATA_SIZE;
ciphertext->size -= AEAD_EXPLICIT_DATA_SIZE;
length_to_decrypt = ciphertext->size - tag_size;
}
else
{
if (ciphertext->size < tag_size)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
length_to_decrypt = ciphertext->size;
}
length = ciphertext->size - tag_size;
/* Pass the type, version, length and compressed through
* MAC.
*/
preamble_size =
make_preamble (UINT64DATA(*sequence), type,
length, ver, preamble);
_gnutls_auth_cipher_add_auth (¶ms->read.cipher_state, preamble, preamble_size);
if ((ret =
_gnutls_auth_cipher_decrypt (¶ms->read.cipher_state,
ciphertext->data, length_to_decrypt)) < 0)
return gnutls_assert_val(ret);
break;
case CIPHER_BLOCK:
if (ciphertext->size < MAX(blocksize, tag_size) || (ciphertext->size % blocksize != 0))
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
/* ignore the IV in TLS 1.1+
*/
if (explicit_iv)
{
_gnutls_auth_cipher_setiv(¶ms->read.cipher_state,
ciphertext->data, blocksize);
ciphertext->size -= blocksize;
ciphertext->data += blocksize;
if (ciphertext->size == 0)
{
gnutls_assert ();
return GNUTLS_E_DECRYPTION_FAILED;
}
}
/* we don't use the auth_cipher interface here, since
* TLS with block ciphers is impossible to be used under such
* an API. (the length of plaintext is required to calculate
* auth_data, but it is not available before decryption).
*/
if ((ret =
_gnutls_cipher_decrypt (¶ms->read.cipher_state.cipher,
ciphertext->data, ciphertext->size)) < 0)
return gnutls_assert_val(ret);
pad = ciphertext->data[ciphertext->size - 1] + 1; /* pad */
if ((int) pad > (int) ciphertext->size - tag_size)
{
gnutls_assert ();
_gnutls_record_log
("REC[%p]: Short record length %d > %d - %d (under attack?)\n",
session, pad, ciphertext->size, tag_size);
/* We do not fail here. We check below for the
* the pad_failed. If zero means success.
*/
pad_failed = GNUTLS_E_DECRYPTION_FAILED;
pad %= blocksize;
}
length = ciphertext->size - tag_size - pad;
/* Check the pading bytes (TLS 1.x)
*/
if (ver != GNUTLS_SSL3)
for (i = 2; i < pad; i++)
{
if (ciphertext->data[ciphertext->size - i] !=
ciphertext->data[ciphertext->size - 1])
pad_failed = GNUTLS_E_DECRYPTION_FAILED;
}
if (length < 0)
{
/* Setting a proper length to prevent timing differences in
* processing of records with invalid encryption.
*/
length = ciphertext->size - tag_size;
}
/* Pass the type, version, length and compressed through
* MAC.
*/
preamble_size =
make_preamble (UINT64DATA(*sequence), type,
length, ver, preamble);
_gnutls_auth_cipher_add_auth (¶ms->read.cipher_state, preamble, preamble_size);
_gnutls_auth_cipher_add_auth (¶ms->read.cipher_state, ciphertext->data, length);
break;
default:
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
}
ret = _gnutls_auth_cipher_tag(¶ms->read.cipher_state, tag, tag_size);
if (ret < 0)
return gnutls_assert_val(ret);
/* This one was introduced to avoid a timing attack against the TLS
* 1.0 protocol.
*/
/* HMAC was not the same.
*/
if (memcmp (tag, &ciphertext->data[length], tag_size) != 0 || pad_failed != 0)
return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED);
/* copy the decrypted stuff to compress_data.
*/
if (compress_size < length)
return gnutls_assert_val(GNUTLS_E_DECOMPRESSION_FAILED);
if (compress_data != ciphertext->data)
memcpy (compress_data, ciphertext->data, length);
return length;
}
|
↓
|
print_crq
|
24
|
125
|
239
|
x509/output.c
|
static void
print_crq (gnutls_buffer_st * str, gnutls_x509_crq_t cert)
{
/* Version. */
{
int version = gnutls_x509_crq_get_version (cert);
if (version < 0)
addf (str, "error: get_version: %s\n", gnutls_strerror (version));
else
addf (str, _("\tVersion: %d\n"), version);
}
/* Subject */
{
char *dn;
size_t dn_size = 0;
int err;
err = gnutls_x509_crq_get_dn (cert, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "error: get_dn: %s\n", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "error: malloc (%d): %s\n", (int) dn_size,
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_x509_crq_get_dn (cert, dn, &dn_size);
if (err < 0)
addf (str, "error: get_dn: %s\n", gnutls_strerror (err));
else
addf (str, _("\tSubject: %s\n"), dn);
gnutls_free (dn);
}
}
}
/* SubjectPublicKeyInfo. */
{
int err;
unsigned int bits;
err = gnutls_x509_crq_get_pk_algorithm (cert, &bits);
if (err < 0)
addf (str, "error: get_pk_algorithm: %s\n", gnutls_strerror (err));
else
{
const char *name = gnutls_pk_algorithm_get_name (err);
if (name == NULL)
name = _("unknown");
addf (str, _("\tSubject Public Key Algorithm: %s\n"), name);
switch (err)
{
case GNUTLS_PK_RSA:
{
gnutls_datum_t m, e;
err = gnutls_x509_crq_get_key_rsa_raw (cert, &m, &e);
if (err < 0)
addf (str, "error: get_pk_rsa_raw: %s\n",
gnutls_strerror (err));
else
{
addf (str, _("\t\tModulus (bits %d):\n"), bits);
_gnutls_buffer_hexdump (str, m.data, m.size, "\t\t\t");
adds (str, _("\t\tExponent:\n"));
_gnutls_buffer_hexdump (str, e.data, e.size, "\t\t\t");
gnutls_free (m.data);
gnutls_free (e.data);
}
}
break;
#if 0 /* not implemented yet */
case GNUTLS_PK_DSA:
{
gnutls_datum_t p, q, g, y;
err = gnutls_x509_crq_get_key_dsa_raw (cert, &p, &q, &g, &y);
if (err < 0)
addf (str, "error: get_pk_dsa_raw: %s\n",
gnutls_strerror (err));
else
{
addf (str, _("\t\tPublic key (bits %d):\n"), bits);
_gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
addf (str, _("\t\tP:\n"));
_gnutls_buffer_hexdump (str, p.data, p.size, "\t\t\t");
addf (str, _("\t\tQ:\n"));
_gnutls_buffer_hexdump (str, q.data, q.size, "\t\t\t");
addf (str, _("\t\tG:\n"));
_gnutls_buffer_hexdump (str, g.data, g.size, "\t\t\t");
gnutls_free (p.data);
gnutls_free (q.data);
gnutls_free (g.data);
gnutls_free (y.data);
}
}
break;
#endif
default:
break;
}
}
}
/* parse attributes */
{
size_t i;
int err = 0;
int extensions = 0;
int challenge = 0;
for (i = 0;; i++)
{
char oid[MAX_OID_SIZE] = "";
size_t sizeof_oid = sizeof (oid);
err = gnutls_x509_crq_get_attribute_info (cert, i, oid, &sizeof_oid);
if (err < 0)
{
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
addf (str, "error: get_extension_info: %s\n",
gnutls_strerror (err));
continue;
}
if (i == 0)
adds (str, _("\tAttributes:\n"));
if (strcmp (oid, "1.2.840.113549.1.9.14") == 0)
{
cert_type_t ccert;
if (extensions)
{
addf (str, "error: more than one extensionsRequest\n");
continue;
}
ccert.crq = cert;
print_extensions (str, "\t", TYPE_CRQ, ccert);
extensions++;
}
else if (strcmp (oid, "1.2.840.113549.1.9.7") == 0)
{
char *pass;
size_t size;
if (challenge)
{
adds (str,
"error: more than one Challenge password attribute\n");
continue;
}
err = gnutls_x509_crq_get_challenge_password (cert, NULL, &size);
if (err < 0)
{
addf (str, "error: get_challenge_password: %s\n",
gnutls_strerror (err));
continue;
}
size++;
pass = gnutls_malloc (size);
if (!pass)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
continue;
}
err = gnutls_x509_crq_get_challenge_password (cert, pass, &size);
if (err < 0)
addf (str, "error: get_challenge_password: %s\n",
gnutls_strerror (err));
else
addf (str, _("\t\tChallenge password: %s\n"), pass);
gnutls_free (pass);
challenge++;
}
else
{
char *buffer;
size_t extlen = 0;
addf (str, _("\t\tUnknown attribute %s:\n"), oid);
err = gnutls_x509_crq_get_attribute_data (cert, i, NULL, &extlen);
if (err < 0)
{
addf (str, "error: get_attribute_data: %s\n",
gnutls_strerror (err));
continue;
}
buffer = gnutls_malloc (extlen);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
continue;
}
err = gnutls_x509_crq_get_attribute_data (cert, i,
buffer, &extlen);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_attribute_data2: %s\n",
gnutls_strerror (err));
continue;
}
adds (str, _("\t\t\tASCII: "));
_gnutls_buffer_asciiprint (str, buffer, extlen);
adds (str, "\n");
adds (str, _("\t\t\tHexdump: "));
_gnutls_buffer_hexprint (str, buffer, extlen);
adds (str, "\n");
gnutls_free (buffer);
}
}
}
}
|
↓
|
_gnutls_asn1_encode_rsa
|
24
|
114
|
212
|
x509/key_encode.c
|
static int
_gnutls_asn1_encode_rsa (ASN1_TYPE * c2, gnutls_pk_params_st * params)
{
int result;
opaque null = '\0';
gnutls_pk_params_st pk_params;
gnutls_datum_t m, e, d, p, q, u, exp1, exp2;
gnutls_pk_params_init(&pk_params);
memset (&m, 0, sizeof (m));
memset (&p, 0, sizeof (p));
memset (&q, 0, sizeof (q));
memset (&p, 0, sizeof (p));
memset (&u, 0, sizeof (u));
memset (&e, 0, sizeof (e));
memset (&d, 0, sizeof (d));
memset (&exp1, 0, sizeof (exp1));
memset (&exp2, 0, sizeof (exp2));
result = _gnutls_pk_params_copy (&pk_params, params);
if (result < 0)
{
gnutls_assert ();
return result;
}
result = _gnutls_pk_fixup (GNUTLS_PK_RSA, GNUTLS_EXPORT, &pk_params);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
/* retrieve as data */
result = _gnutls_mpi_dprint_lz (pk_params.params[0], &m);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[1], &e);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[2], &d);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[3], &p);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[4], &q);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[5], &u);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[6], &exp1);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_mpi_dprint_lz (pk_params.params[7], &exp2);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
/* Ok. Now we have the data. Create the asn1 structures
*/
/* first make sure that no previously allocated data are leaked */
if (*c2 != ASN1_TYPE_EMPTY)
{
asn1_delete_structure (c2);
*c2 = ASN1_TYPE_EMPTY;
}
if ((result = asn1_create_element
(_gnutls_get_gnutls_asn (), "GNUTLS.RSAPrivateKey", c2))
!= ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Write PRIME
*/
if ((result = asn1_write_value (*c2, "modulus",
m.data, m.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "publicExponent",
e.data, e.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "privateExponent",
d.data, d.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "prime1",
p.data, p.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "prime2",
q.data, q.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "coefficient",
u.data, u.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "exponent1",
exp1.data, exp1.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "exponent2",
exp2.data, exp2.size)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "otherPrimeInfos",
NULL, 0)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
result = 0;
cleanup:
if (result != 0)
asn1_delete_structure (c2);
gnutls_pk_params_release (&pk_params);
_gnutls_free_datum (&m);
_gnutls_free_datum (&d);
_gnutls_free_datum (&e);
_gnutls_free_datum (&p);
_gnutls_free_datum (&q);
_gnutls_free_datum (&u);
_gnutls_free_datum (&exp1);
_gnutls_free_datum (&exp2);
return result;
}
|
↓
|
cdk_keydb_search
|
23
|
55
|
103
|
opencdk/keydb.c
|
cdk_error_t
cdk_keydb_search (cdk_keydb_search_t st, cdk_keydb_hd_t hd,
cdk_kbnode_t * ret_key)
{
cdk_stream_t kr;
cdk_kbnode_t knode;
cdk_error_t rc = 0;
off_t pos = 0, off = 0;
int key_found = 0, cache_hit = 0;
if (!hd || !ret_key || !st)
{
gnutls_assert ();
return CDK_Inv_Value;
}
*ret_key = NULL;
kr = NULL;
rc = _cdk_keydb_open (hd, &kr);
if (rc)
{
gnutls_assert ();
return rc;
}
if (!st->no_cache)
{
/* It is possible the index is not up-to-date and thus we do
not find the requesed key. In this case, we reset cache hit
and continue our normal search procedure. */
rc = keydb_pos_from_cache (hd, st, &cache_hit, &off);
if (rc)
cache_hit = 0;
}
knode = NULL;
while (!key_found && !rc)
{
if (cache_hit && st->type != CDK_DBSEARCH_NEXT)
cdk_stream_seek (kr, off);
else if (st->type == CDK_DBSEARCH_NEXT)
cdk_stream_seek (kr, st->off);
pos = cdk_stream_tell (kr);
rc = cdk_keydb_get_keyblock (kr, &knode);
if (rc)
{
if (rc == CDK_EOF)
break;
else
{
gnutls_assert ();
return rc;
}
}
switch (st->type)
{
case CDK_DBSEARCH_SHORT_KEYID:
case CDK_DBSEARCH_KEYID:
key_found = find_by_keyid (knode, st);
break;
case CDK_DBSEARCH_FPR:
key_found = find_by_fpr (knode, st);
break;
case CDK_DBSEARCH_EXACT:
case CDK_DBSEARCH_SUBSTR:
key_found = find_by_pattern (knode, st);
break;
case CDK_DBSEARCH_NEXT:
st->off = cdk_stream_tell (kr);
key_found = knode ? 1 : 0;
break;
}
if (key_found)
{
if (!keydb_cache_find (st))
keydb_cache_add (st, pos);
break;
}
cdk_kbnode_release (knode);
knode = NULL;
}
if (key_found && rc == CDK_EOF)
rc = 0;
else if (rc == CDK_EOF && !key_found)
{
gnutls_assert ();
rc = CDK_Error_No_Key;
}
*ret_key = key_found ? knode : NULL;
return rc;
}
|
↓
|
ecc_projective_add_point
|
23
|
93
|
184
|
nettle/ecc_projective_add_point.c
|
int
ecc_projective_add_point (ecc_point * P, ecc_point * Q, ecc_point * R,
mpz_t a, mpz_t modulus)
{
mpz_t t1, t2, x, y, z;
int err;
if (P == NULL || Q == NULL || R == NULL || modulus == NULL)
return -1;
if ((err = mp_init_multi (&t1, &t2, &x, &y, &z, NULL)) != 0)
{
return err;
}
/* Check if P == Q and do doubling in that case
* If Q == -P then P+Q=point at infinity
*/
if ((mpz_cmp (P->x, Q->x) == 0) &&
(mpz_cmp (P->z, Q->z) == 0))
{
/* x and z coordinates match. Check if P->y = Q->y, or P->y = -Q->y
*/
if (mpz_cmp (P->y, Q->y) == 0)
{
mp_clear_multi (&t1, &t2, &x, &y, &z, NULL);
return ecc_projective_dbl_point (P, R, a, modulus);
}
mpz_sub (t1, modulus, Q->y);
if (mpz_cmp (P->y, t1) == 0)
{
mp_clear_multi (&t1, &t2, &x, &y, &z, NULL);
mpz_set_ui(R->x, 1);
mpz_set_ui(R->y, 1);
mpz_set_ui(R->z, 0);
return 0;
}
}
mpz_set (x, P->x);
mpz_set (y, P->y);
mpz_set (z, P->z);
/* if Z is one then these are no-operations */
if (mpz_cmp_ui (Q->z, 1) != 0)
{
/* T1 = Z' * Z' */
mpz_mul (t1, Q->z, Q->z);
mpz_mod (t1, t1, modulus);
/* X = X * T1 */
mpz_mul (x, x, t1);
mpz_mod (x, x, modulus);
/* T1 = Z' * T1 */
mpz_mul (t1, t1, Q->z);
mpz_mod (t1, t1, modulus);
/* Y = Y * T1 */
mpz_mul (y, y, t1);
mpz_mod (y, y, modulus);
}
/* T1 = Z*Z */
mpz_mul (t1, z, z);
mpz_mod (t1, t1, modulus);
/* T2 = X' * T1 */
mpz_mul (t2, t1, Q->x);
mpz_mod (t2, t2, modulus);
/* T1 = Z * T1 */
mpz_mul (t1, t1, z);
mpz_mod (t1, t1, modulus);
/* T1 = Y' * T1 */
mpz_mul (t1, t1, Q->y);
mpz_mod (t1, t1, modulus);
/* Y = Y - T1 */
mpz_sub (y, y, t1);
if (mpz_cmp_ui (y, 0) < 0)
{
mpz_add (y, y, modulus);
}
/* T1 = 2T1 */
mpz_add (t1, t1, t1);
if (mpz_cmp (t1, modulus) >= 0)
{
mpz_sub (t1, t1, modulus);
}
/* T1 = Y + T1 */
mpz_add (t1, t1, y);
if (mpz_cmp (t1, modulus) >= 0)
{
mpz_sub (t1, t1, modulus);
}
/* X = X - T2 */
mpz_sub (x, x, t2);
if (mpz_cmp_ui (x, 0) < 0)
{
mpz_add (x, x, modulus);
}
/* T2 = 2T2 */
mpz_add (t2, t2, t2);
if (mpz_cmp (t2, modulus) >= 0)
{
mpz_sub (t2, t2, modulus);
}
/* T2 = X + T2 */
mpz_add (t2, t2, x);
if (mpz_cmp (t2, modulus) >= 0)
{
mpz_sub (t2, t2, modulus);
}
/* if Z' != 1 */
if (mpz_cmp_ui (Q->z, 1) != 0)
{
/* Z = Z * Z' */
mpz_mul (z, z, Q->z);
mpz_mod (z, z, modulus);
}
/* Z = Z * X */
mpz_mul (z, z, x);
mpz_mod (z, z, modulus);
/* T1 = T1 * X */
mpz_mul (t1, t1, x);
mpz_mod (t1, t1, modulus);
/* X = X * X */
mpz_mul (x, x, x);
mpz_mod (x, x, modulus);
/* T2 = T2 * x */
mpz_mul (t2, t2, x);
mpz_mod (t2, t2, modulus);
/* T1 = T1 * X */
mpz_mul (t1, t1, x);
mpz_mod (t1, t1, modulus);
/* X = Y*Y */
mpz_mul (x, y, y);
mpz_mod (x, x, modulus);
/* X = X - T2 */
mpz_sub (x, x, t2);
if (mpz_cmp_ui (x, 0) < 0)
{
mpz_add (x, x, modulus);
}
/* T2 = T2 - X */
mpz_sub (t2, t2, x);
if (mpz_cmp_ui (t2, 0) < 0)
{
mpz_add (t2, t2, modulus);
}
/* T2 = T2 - X */
mpz_sub (t2, t2, x);
if (mpz_cmp_ui (t2, 0) < 0)
{
mpz_add (t2, t2, modulus);
}
/* T2 = T2 * Y */
mpz_mul (t2, t2, y);
mpz_mod (t2, t2, modulus);
/* Y = T2 - T1 */
mpz_sub (y, t2, t1);
if (mpz_cmp_ui (y, 0) < 0)
{
mpz_add (y, y, modulus);
}
/* Y = Y/2 */
if (mpz_odd_p (y))
{
mpz_add (y, y, modulus);
}
mpz_divexact_ui (y, y, 2);
mpz_set (R->x, x);
mpz_set (R->y, y);
mpz_set (R->z, z);
err = 0;
mp_clear_multi (&t1, &t2, &x, &y, &z, NULL);
return err;
}
|
↓
|
_pkcs12_decode_safe_contents
|
23
|
93
|
190
|
x509/pkcs12.c
|
int
_pkcs12_decode_safe_contents (const gnutls_datum_t * content,
gnutls_pkcs12_bag_t bag)
{
char oid[MAX_OID_SIZE], root[ASN1_MAX_NAME_SIZE];
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int len, result;
int bag_type;
gnutls_datum_t attr_val;
int count = 0, i, attributes, j;
size_t size;
/* Step 1. Extract the SEQUENCE.
*/
if ((result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.pkcs-12-SafeContents",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
result = asn1_der_decoding (&c2, content->data, content->size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Count the number of bags
*/
result = asn1_number_of_elements (c2, "", &count);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
bag->bag_elements = MIN (MAX_BAG_ELEMENTS, count);
for (i = 0; i < bag->bag_elements; i++)
{
snprintf (root, sizeof (root), "?%u.bagId", i + 1);
len = sizeof (oid);
result = asn1_read_value (c2, root, oid, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Read the Bag type
*/
bag_type = oid2bag (oid);
if (bag_type < 0)
{
gnutls_assert ();
goto cleanup;
}
/* Read the Bag Value
*/
snprintf (root, sizeof (root), "?%u.bagValue", i + 1);
result = _gnutls_x509_read_value (c2, root, &bag->element[i].data, 0);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
if (bag_type == GNUTLS_BAG_CERTIFICATE || bag_type == GNUTLS_BAG_CRL
|| bag_type == GNUTLS_BAG_SECRET)
{
gnutls_datum_t tmp = bag->element[i].data;
result =
_pkcs12_decode_crt_bag (bag_type, &tmp, &bag->element[i].data);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
_gnutls_free_datum (&tmp);
}
/* read the bag attributes
*/
snprintf (root, sizeof (root), "?%u.bagAttributes", i + 1);
result = asn1_number_of_elements (c2, root, &attributes);
if (result != ASN1_SUCCESS && result != ASN1_ELEMENT_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (attributes < 0)
attributes = 1;
if (result != ASN1_ELEMENT_NOT_FOUND)
for (j = 0; j < attributes; j++)
{
snprintf (root, sizeof (root), "?%u.bagAttributes.?%u", i + 1,
j + 1);
result =
_gnutls_x509_decode_and_read_attribute (c2, root, oid,
sizeof (oid), &attr_val,
1, 0);
if (result < 0)
{
gnutls_assert ();
continue; /* continue in case we find some known attributes */
}
if (strcmp (oid, KEY_ID_OID) == 0)
{
size = attr_val.size;
result =
_gnutls_x509_decode_octet_string (NULL, attr_val.data, size,
attr_val.data, &size);
attr_val.size = size;
if (result < 0)
{
_gnutls_free_datum (&attr_val);
gnutls_assert ();
_gnutls_debug_log
("Error decoding PKCS12 Bag Attribute OID '%s'\n", oid);
continue;
}
bag->element[i].local_key_id = attr_val;
}
else if (strcmp (oid, FRIENDLY_NAME_OID) == 0)
{
size = attr_val.size;
result =
_gnutls_x509_decode_octet_string ("BMPString",
attr_val.data, size,
attr_val.data, &size);
attr_val.size = size;
if (result < 0)
{
_gnutls_free_datum (&attr_val);
gnutls_assert ();
_gnutls_debug_log
("Error decoding PKCS12 Bag Attribute OID '%s'\n", oid);
continue;
}
bag->element[i].friendly_name =
ucs2_to_ascii (attr_val.data, attr_val.size);
}
else
{
_gnutls_free_datum (&attr_val);
_gnutls_debug_log
("Unknown PKCS12 Bag Attribute OID '%s'\n", oid);
}
}
bag->element[i].type = bag_type;
}
asn1_delete_structure (&c2);
return 0;
cleanup:
if (c2)
asn1_delete_structure (&c2);
return result;
}
|
↓
|
_gnutls_proc_openpgp_server_certificate
|
23
|
93
|
197
|
auth/cert.c
|
static int
_gnutls_proc_openpgp_server_certificate (gnutls_session_t session,
opaque * data, size_t data_size)
{
int size, ret, len;
opaque *p = data;
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
ssize_t dsize = data_size;
int x, key_type;
gnutls_pcert_st *peer_certificate_list = NULL;
int peer_certificate_list_size = 0;
gnutls_datum_t tmp, akey = { NULL, 0 };
uint8_t subkey_id[GNUTLS_OPENPGP_KEYID_SIZE];
unsigned int subkey_id_set = 0;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if ((ret =
_gnutls_auth_info_set (session, GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
if (data == NULL || data_size == 0)
{
gnutls_assert ();
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
DECR_LEN (dsize, 3);
size = _gnutls_read_uint24 (p);
p += 3;
if (size == 0)
{
gnutls_assert ();
/* no certificate was sent */
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
/* Read PGPKeyDescriptor */
DECR_LEN (dsize, 1);
key_type = *p;
p++;
/* Try to read the keyid if present */
if (key_type == PGP_KEY_FINGERPRINT_SUBKEY || key_type == PGP_KEY_SUBKEY)
{
/* check size */
if (*p != GNUTLS_OPENPGP_KEYID_SIZE)
{
gnutls_assert ();
return GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;
}
DECR_LEN (dsize, 1);
p++;
DECR_LEN (dsize, GNUTLS_OPENPGP_KEYID_SIZE);
memcpy (subkey_id, p, GNUTLS_OPENPGP_KEYID_SIZE);
p += GNUTLS_OPENPGP_KEYID_SIZE;
subkey_id_set = 1;
}
/* read the actual key or fingerprint */
if (key_type == PGP_KEY_FINGERPRINT
|| key_type == PGP_KEY_FINGERPRINT_SUBKEY)
{ /* the fingerprint */
DECR_LEN (dsize, 1);
len = (uint8_t) * p;
p++;
if (len != 20)
{
gnutls_assert ();
return GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED;
}
DECR_LEN (dsize, 20);
/* request the actual key from our database, or
* a key server or anything.
*/
if ((ret =
_gnutls_openpgp_request_key (session, &akey, cred, p, 20)) < 0)
{
gnutls_assert ();
return ret;
}
tmp = akey;
peer_certificate_list_size++;
}
else if (key_type == PGP_KEY || key_type == PGP_KEY_SUBKEY)
{ /* the whole key */
/* Read the actual certificate */
DECR_LEN (dsize, 3);
len = _gnutls_read_uint24 (p);
p += 3;
if (len == 0)
{
gnutls_assert ();
/* no certificate was sent */
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
DECR_LEN (dsize, len);
peer_certificate_list_size++;
tmp.size = len;
tmp.data = p;
}
else
{
gnutls_assert ();
return GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;
}
/* ok we now have the peer's key in tmp datum
*/
if (peer_certificate_list_size == 0)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
peer_certificate_list =
gnutls_calloc (1,
sizeof (gnutls_pcert_st) * (peer_certificate_list_size));
if (peer_certificate_list == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
ret =
gnutls_pcert_import_openpgp_raw (&peer_certificate_list[0],
&tmp,
GNUTLS_OPENPGP_FMT_RAW,
(subkey_id_set != 0) ? subkey_id : NULL,
0);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
ret =
_gnutls_copy_certificate_auth_info (info,
peer_certificate_list,
peer_certificate_list_size,
subkey_id_set,
(subkey_id_set !=
0) ? subkey_id : NULL);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
if ((ret =
_gnutls_check_key_usage (&peer_certificate_list[0],
gnutls_kx_get (session))) < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = 0;
cleanup:
_gnutls_free_datum (&akey);
CLEAR_CERTS;
gnutls_free (peer_certificate_list);
return ret;
}
|
↓
|
parse_record_buffered_msgs
|
23
|
77
|
159
|
gnutls_buffers.c
|
static int
parse_record_buffered_msgs (gnutls_session_t session,
gnutls_handshake_description_t htype,
handshake_buffer_st * hsk)
{
gnutls_datum_t msg;
mbuffer_st* bufel = NULL, *prev = NULL;
int ret;
size_t data_size;
handshake_buffer_st* recv_buf = session->internals.handshake_recv_buffer;
bufel = _mbuffer_head_get_first(&session->internals.record_buffer, &msg);
if (bufel == NULL)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
if (!IS_DTLS(session))
{
ssize_t remain, append, header_size;
do
{
if (bufel->type != GNUTLS_HANDSHAKE)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
/* if we have a half received message the complete it.
*/
remain = recv_buf[0].length -
recv_buf[0].data.length;
/* this is the rest of a previous message */
if (session->internals.handshake_recv_buffer_size > 0 && recv_buf[0].length > 0 && remain > 0)
{
if (msg.size <= remain)
append = msg.size;
else
append = remain;
ret = _gnutls_buffer_append_data(&recv_buf[0].data, msg.data, append);
if (ret < 0)
return gnutls_assert_val(ret);
_mbuffer_head_remove_bytes(&session->internals.record_buffer, append);
}
else /* received new message */
{
ret = parse_handshake_header(session, bufel, htype, &recv_buf[0]);
if (ret < 0)
return gnutls_assert_val(ret);
header_size = ret;
session->internals.handshake_recv_buffer_size = 1;
_mbuffer_set_uhead_size(bufel, header_size);
data_size = MIN(recv_buf[0].length, _mbuffer_get_udata_size(bufel));
ret = _gnutls_buffer_append_data(&recv_buf[0].data, _mbuffer_get_udata_ptr(bufel), data_size);
if (ret < 0)
return gnutls_assert_val(ret);
_mbuffer_set_uhead_size(bufel, 0);
_mbuffer_head_remove_bytes(&session->internals.record_buffer, data_size+header_size);
if (cmp_hsk_types(htype, recv_buf[0].htype) == 0)
{ /* an unexpected packet */
hsk->htype = recv_buf[0].htype;
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET);
}
}
/* if packet is complete then return it
*/
if (recv_buf[0].length ==
recv_buf[0].data.length)
{
return get_last_packet(session, htype, hsk);
}
bufel = _mbuffer_head_get_first(&session->internals.record_buffer, &msg);
}
while(bufel != NULL);
/* if we are here it means that the received packets were not
* enough to complete the handshake packet.
*/
return gnutls_assert_val(GNUTLS_E_AGAIN);
}
else /* DTLS */
{
handshake_buffer_st tmp;
do
{
/* we now
* 0. parse headers
* 1. insert to handshake_recv_buffer
* 2. sort handshake_recv_buffer on sequence numbers
* 3. return first packet if completed or GNUTLS_E_AGAIN.
*/
do
{
if (bufel->type != GNUTLS_HANDSHAKE)
{
gnutls_assert();
goto next; /* ignore packet */
}
_gnutls_handshake_buffer_init(&tmp);
ret = parse_handshake_header(session, bufel, htype, &tmp);
if (ret < 0)
{
gnutls_assert();
_gnutls_audit_log(session, "Invalid handshake packet headers. Discarding.\n");
break;
}
_mbuffer_consume(&session->internals.record_buffer, bufel, ret);
data_size = MIN(tmp.length, tmp.end_offset-tmp.start_offset+1);
ret = _gnutls_buffer_append_data(&tmp.data, _mbuffer_get_udata_ptr(bufel), data_size);
if (ret < 0)
return gnutls_assert_val(ret);
_mbuffer_consume(&session->internals.record_buffer, bufel, data_size);
ret = merge_handshake_packet(session, &tmp);
if (ret < 0)
return gnutls_assert_val(ret);
}
while(_mbuffer_get_udata_size(bufel) > 0);
prev = bufel;
bufel = _mbuffer_dequeue(&session->internals.record_buffer, bufel);
_mbuffer_xfree(&prev);
continue;
next:
bufel = _mbuffer_head_get_next(bufel, NULL);
}
while(bufel != NULL);
/* sort in descending order */
if (session->internals.handshake_recv_buffer_size > 1)
qsort(recv_buf, session->internals.handshake_recv_buffer_size,
sizeof(recv_buf[0]), handshake_compare);
while(session->internals.handshake_recv_buffer_size > 0 &&
recv_buf[LAST_ELEMENT].sequence < session->internals.dtls.hsk_read_seq)
{
_gnutls_audit_log(session, "Discarded replayed handshake packet with sequence %d\n", recv_buf[LAST_ELEMENT].sequence);
_gnutls_handshake_buffer_clear(&recv_buf[LAST_ELEMENT]);
session->internals.handshake_recv_buffer_size--;
}
return get_last_packet(session, htype, hsk);
}
}
|
↓
|
_gnutls_pkcs12_string_to_key
|
23
|
101
|
145
|
x509/pkcs12_encr.c
|
int
_gnutls_pkcs12_string_to_key (unsigned int id, const opaque * salt,
unsigned int salt_size, unsigned int iter,
const char *pw, unsigned int req_keylen,
opaque * keybuf)
{
int rc;
unsigned int i, j;
digest_hd_st md;
bigint_t num_b1 = NULL, num_ij = NULL;
bigint_t mpi512 = NULL;
unsigned int pwlen;
opaque hash[20], buf_b[64], buf_i[128], *p;
size_t cur_keylen;
size_t n, m;
const opaque buf_512[] = /* 2^64 */
{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
cur_keylen = 0;
if (pw == NULL)
pwlen = 0;
else
pwlen = strlen (pw);
if (pwlen > 63 / 2)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if ((rc = _pkcs12_check_pass (pw, pwlen)) < 0)
{
gnutls_assert ();
return rc;
}
rc = _gnutls_mpi_scan (&mpi512, buf_512, sizeof (buf_512));
if (rc < 0)
{
gnutls_assert ();
return rc;
}
/* Store salt and password in BUF_I */
p = buf_i;
for (i = 0; i < 64; i++)
*p++ = salt[i % salt_size];
if (pw)
{
for (i = j = 0; i < 64; i += 2)
{
*p++ = 0;
*p++ = pw[j];
if (++j > pwlen) /* Note, that we include the trailing (0) */
j = 0;
}
}
else
memset (p, 0, 64);
for (;;)
{
rc = _gnutls_hash_init (&md, GNUTLS_MAC_SHA1);
if (rc < 0)
{
gnutls_assert ();
goto cleanup;
}
for (i = 0; i < 64; i++)
{
unsigned char lid = id & 0xFF;
_gnutls_hash (&md, &lid, 1);
}
_gnutls_hash (&md, buf_i, pw ? 128 : 64);
_gnutls_hash_deinit (&md, hash);
for (i = 1; i < iter; i++)
{
rc = _gnutls_hash_init (&md, GNUTLS_MAC_SHA1);
if (rc < 0)
{
gnutls_assert ();
goto cleanup;
}
_gnutls_hash (&md, hash, 20);
_gnutls_hash_deinit (&md, hash);
}
for (i = 0; i < 20 && cur_keylen < req_keylen; i++)
keybuf[cur_keylen++] = hash[i];
if (cur_keylen == req_keylen)
{
rc = 0; /* ready */
goto cleanup;
}
/* need more bytes. */
for (i = 0; i < 64; i++)
buf_b[i] = hash[i % 20];
n = 64;
rc = _gnutls_mpi_scan (&num_b1, buf_b, n);
if (rc < 0)
{
gnutls_assert ();
goto cleanup;
}
_gnutls_mpi_add_ui (num_b1, num_b1, 1);
for (i = 0; i < 128; i += 64)
{
n = 64;
rc = _gnutls_mpi_scan (&num_ij, buf_i + i, n);
if (rc < 0)
{
gnutls_assert ();
goto cleanup;
}
_gnutls_mpi_addm (num_ij, num_ij, num_b1, mpi512);
n = 64;
#ifndef PKCS12_BROKEN_KEYGEN
m = (_gnutls_mpi_get_nbits (num_ij) + 7) / 8;
#else
m = n;
#endif
memset (buf_i + i, 0, n - m);
rc = _gnutls_mpi_print (num_ij, buf_i + i + n - m, &n);
if (rc < 0)
{
gnutls_assert ();
goto cleanup;
}
_gnutls_mpi_release (&num_ij);
}
}
cleanup:
_gnutls_mpi_release (&num_ij);
_gnutls_mpi_release (&num_b1);
_gnutls_mpi_release (&mpi512);
return rc;
}
|
↓
|
_gnutls_server_select_suite
|
22
|
76
|
171
|
gnutls_handshake.c
|
int
_gnutls_server_select_suite (gnutls_session_t session, opaque * data,
int datalen)
{
int i, j, ret, cipher_suites_size;
size_t pk_algos_size;
uint8_t cipher_suites[MAX_CIPHERSUITE_SIZE];
int retval, err;
gnutls_pk_algorithm_t pk_algos[MAX_ALGOS]; /* will hold the pk algorithms
* supported by the peer.
*/
/* First, check for safe renegotiation SCSV.
*/
if (session->internals.priorities.sr != SR_DISABLED)
{
int offset;
for (offset = 0; offset < datalen; offset += 2)
{
/* TLS_RENEGO_PROTECTION_REQUEST = { 0x00, 0xff } */
if (data[offset] == GNUTLS_RENEGO_PROTECTION_REQUEST_MAJOR &&
data[offset + 1] == GNUTLS_RENEGO_PROTECTION_REQUEST_MINOR)
{
_gnutls_handshake_log
("HSK[%p]: Received safe renegotiation CS\n", session);
retval = _gnutls_ext_sr_recv_cs (session);
if (retval < 0)
{
gnutls_assert ();
return retval;
}
break;
}
}
}
pk_algos_size = MAX_ALGOS;
ret = server_find_pk_algos_in_ciphersuites (data, datalen, pk_algos, &pk_algos_size);
if (ret < 0)
return gnutls_assert_val(ret);
ret = _gnutls_supported_ciphersuites (session, cipher_suites, sizeof(cipher_suites));
if (ret < 0)
return gnutls_assert_val(ret);
cipher_suites_size = ret;
/* Here we remove any ciphersuite that does not conform
* the certificate requested, or to the
* authentication requested (e.g. SRP).
*/
ret = _gnutls_remove_unwanted_ciphersuites (session, cipher_suites, cipher_suites_size, pk_algos, pk_algos_size);
if (ret <= 0)
{
gnutls_assert ();
if (ret < 0)
return ret;
else
return GNUTLS_E_UNKNOWN_CIPHER_SUITE;
}
cipher_suites_size = ret;
/* Data length should be zero mod 2 since
* every ciphersuite is 2 bytes. (this check is needed
* see below).
*/
if (datalen % 2 != 0)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
memset (session->security_parameters.cipher_suite, 0, 2);
retval = GNUTLS_E_UNKNOWN_CIPHER_SUITE;
_gnutls_handshake_log ("HSK[%p]: Requested cipher suites[size: %d]: \n", session, (int)datalen);
if (session->internals.priorities.server_precedence == 0)
{
for (j = 0; j < datalen; j += 2)
{
_gnutls_handshake_log ("\t0x%.2x, 0x%.2x %s\n", data[j], data[j+1], _gnutls_cipher_suite_get_name (&data[j]));
for (i = 0; i < cipher_suites_size; i+=2)
{
if (memcmp (&cipher_suites[i], &data[j], 2) == 0)
{
_gnutls_handshake_log
("HSK[%p]: Selected cipher suite: %s\n", session,
_gnutls_cipher_suite_get_name (&data[j]));
memcpy (session->security_parameters.cipher_suite,
&cipher_suites[i], 2);
_gnutls_epoch_set_cipher_suite (session, EPOCH_NEXT,
session->
security_parameters.cipher_suite);
retval = 0;
goto finish;
}
}
}
}
else /* server selects */
{
for (i = 0; i < cipher_suites_size; i+=2)
{
for (j = 0; j < datalen; j += 2)
{
if (memcmp (&cipher_suites[i], &data[j], 2) == 0)
{
_gnutls_handshake_log
("HSK[%p]: Selected cipher suite: %s\n", session,
_gnutls_cipher_suite_get_name (&data[j]));
memcpy (session->security_parameters.cipher_suite,
&cipher_suites[i], 2);
_gnutls_epoch_set_cipher_suite (session, EPOCH_NEXT,
session->
security_parameters.cipher_suite);
retval = 0;
goto finish;
}
}
}
}
finish:
if (retval != 0)
{
gnutls_assert ();
return retval;
}
/* check if the credentials (username, public key etc.) are ok
*/
if (_gnutls_get_kx_cred
(session,
_gnutls_cipher_suite_get_kx_algo (session->
security_parameters.cipher_suite),
&err) == NULL && err != 0)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* set the mod_auth_st to the appropriate struct
* according to the KX algorithm. This is needed since all the
* handshake functions are read from there;
*/
session->internals.auth_struct =
_gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo
(session->
security_parameters.cipher_suite));
if (session->internals.auth_struct == NULL)
{
_gnutls_handshake_log
("HSK[%p]: Cannot find the appropriate handler for the KX algorithm\n",
session);
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
return 0;
}
|
↓
|
_cdk_pk_check_sig
|
22
|
69
|
113
|
opencdk/sig-check.c
|
cdk_error_t
_cdk_pk_check_sig (cdk_keydb_hd_t keydb,
cdk_kbnode_t knode, cdk_kbnode_t snode, int *is_selfsig,
char **ret_uid)
{
digest_hd_st md;
int err;
cdk_pubkey_t pk;
cdk_pkt_signature_t sig;
cdk_kbnode_t node;
cdk_error_t rc = 0;
int is_expired;
if (!knode || !snode)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (is_selfsig)
*is_selfsig = 0;
if ((knode->pkt->pkttype != CDK_PKT_PUBLIC_KEY &&
knode->pkt->pkttype != CDK_PKT_PUBLIC_SUBKEY) ||
snode->pkt->pkttype != CDK_PKT_SIGNATURE)
{
gnutls_assert ();
return CDK_Inv_Value;
}
pk = knode->pkt->pkt.public_key;
sig = snode->pkt->pkt.signature;
err = _gnutls_hash_init (&md, sig->digest_algo);
if (err < 0)
{
gnutls_assert ();
return map_gnutls_error (err);
}
is_expired = 0;
if (sig->sig_class == 0x20)
{ /* key revocation */
cdk_kbnode_hash (knode, &md, 0, 0, 0);
rc = _cdk_sig_check (pk, sig, &md, &is_expired);
}
else if (sig->sig_class == 0x28)
{ /* subkey revocation */
node = cdk_kbnode_find_prev (knode, snode, CDK_PKT_PUBLIC_SUBKEY);
if (!node)
{ /* no subkey for subkey revocation packet */
gnutls_assert ();
rc = CDK_Error_No_Key;
goto fail;
}
cdk_kbnode_hash (knode, &md, 0, 0, 0);
cdk_kbnode_hash (node, &md, 0, 0, 0);
rc = _cdk_sig_check (pk, sig, &md, &is_expired);
}
else if (sig->sig_class == 0x18 || sig->sig_class == 0x19)
{ /* primary/secondary key binding */
node = cdk_kbnode_find_prev (knode, snode, CDK_PKT_PUBLIC_SUBKEY);
if (!node)
{ /* no subkey for subkey binding packet */
gnutls_assert ();
rc = CDK_Error_No_Key;
goto fail;
}
cdk_kbnode_hash (knode, &md, 0, 0, 0);
cdk_kbnode_hash (node, &md, 0, 0, 0);
rc = _cdk_sig_check (pk, sig, &md, &is_expired);
}
else if (sig->sig_class == 0x1F)
{ /* direct key signature */
cdk_kbnode_hash (knode, &md, 0, 0, 0);
rc = _cdk_sig_check (pk, sig, &md, &is_expired);
}
else
{ /* all other classes */
cdk_pkt_userid_t uid;
node = cdk_kbnode_find_prev (knode, snode, CDK_PKT_USER_ID);
if (!node)
{ /* no user ID for key signature packet */
gnutls_assert ();
rc = CDK_Error_No_Key;
goto fail;
}
uid = node->pkt->pkt.user_id;
if (ret_uid)
{
*ret_uid = uid->name;
}
cdk_kbnode_hash (knode, &md, 0, 0, 0);
cdk_kbnode_hash (node, &md, sig->version == 4, 0, 0);
if (pk->keyid[0] == sig->keyid[0] && pk->keyid[1] == sig->keyid[1])
{
rc = _cdk_sig_check (pk, sig, &md, &is_expired);
if (is_selfsig)
*is_selfsig = 1;
}
else if (keydb != NULL)
{
cdk_pubkey_t sig_pk;
rc = cdk_keydb_get_pk (keydb, sig->keyid, &sig_pk);
if (!rc)
rc = _cdk_sig_check (sig_pk, sig, &md, &is_expired);
cdk_pk_release (sig_pk);
}
}
fail:
_gnutls_hash_deinit (&md, NULL);
return rc;
}
|
↓
|
_gnutls_send_int
|
22
|
68
|
145
|
gnutls_record.c
|
ssize_t
_gnutls_send_int (gnutls_session_t session, content_type_t type,
gnutls_handshake_description_t htype,
unsigned int epoch_rel, const void *_data,
size_t data_size, unsigned int mflags)
{
mbuffer_st *bufel;
ssize_t cipher_size;
int retval, ret;
int send_data_size;
uint8_t headers[MAX_RECORD_HEADER_SIZE];
int header_size;
const uint8_t *data = _data;
record_parameters_st *record_params;
record_state_st *record_state;
ret = _gnutls_epoch_get (session, epoch_rel, &record_params);
if (ret < 0)
return gnutls_assert_val(ret);
/* Safeguard against processing data with an incomplete cipher state. */
if (!record_params->initialized)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
record_state = &record_params->write;
/* Do not allow null pointer if the send buffer is empty.
* If the previous send was interrupted then a null pointer is
* ok, and means to resume.
*/
if (session->internals.record_send_buffer.byte_length == 0 &&
(data_size == 0 && _data == NULL))
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (type != GNUTLS_ALERT) /* alert messages are sent anyway */
if (session_is_valid (session) || session->internals.may_not_write != 0)
{
gnutls_assert ();
return GNUTLS_E_INVALID_SESSION;
}
headers[0] = type;
/* Use the default record version, if it is
* set.
*/
copy_record_version (session, htype, &headers[1]);
header_size = RECORD_HEADER_SIZE(session);
/* Adjust header length and add sequence for DTLS */
if (IS_DTLS(session))
memcpy(&headers[3], &record_state->sequence_number.i, 8);
_gnutls_record_log
("REC[%p]: Preparing Packet %s(%d) with length: %d\n", session,
_gnutls_packet2str (type), type, (int) data_size);
if (data_size > MAX_RECORD_SEND_SIZE(session))
send_data_size = MAX_RECORD_SEND_SIZE(session);
else
send_data_size = data_size;
/* Only encrypt if we don't have data to send
* from the previous run. - probably interrupted.
*/
if (mflags != 0 && session->internals.record_send_buffer.byte_length > 0)
{
ret = _gnutls_io_write_flush (session);
if (ret > 0)
cipher_size = ret;
else
cipher_size = 0;
retval = session->internals.record_send_buffer_user_size;
}
else
{
/* now proceed to packet encryption
*/
cipher_size = send_data_size + MAX_RECORD_OVERHEAD;
bufel = _mbuffer_alloc (cipher_size, cipher_size);
if (bufel == NULL)
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
ret =
_gnutls_encrypt (session, headers, header_size, data,
send_data_size, _mbuffer_get_udata_ptr (bufel),
cipher_size, type, record_params);
if (ret <= 0)
{
gnutls_assert ();
if (ret == 0)
ret = GNUTLS_E_ENCRYPTION_FAILED;
gnutls_free (bufel);
return ret; /* error */
}
cipher_size = ret;
retval = send_data_size;
session->internals.record_send_buffer_user_size = send_data_size;
/* increase sequence number
*/
if (sequence_increment (session, &record_state->sequence_number) != 0)
{
session_invalidate (session);
gnutls_free (bufel);
return gnutls_assert_val(GNUTLS_E_RECORD_LIMIT_REACHED);
}
_mbuffer_set_udata_size (bufel, cipher_size);
ret = _gnutls_io_write_buffered (session, bufel, mflags);
}
if (ret != cipher_size)
{
/* If we have sent any data then just return
* the error value. Do not invalidate the session.
*/
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
return gnutls_assert_val(ret);
if (ret > 0)
ret = gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
session_unresumable (session);
session->internals.may_not_write = 1;
return gnutls_assert_val(ret);
}
session->internals.record_send_buffer_user_size = 0;
_gnutls_record_log ("REC[%p]: Sent Packet[%d] %s(%d) with length: %d\n",
session,
(unsigned int)
_gnutls_uint64touint32
(&record_state->sequence_number),
_gnutls_packet2str (type), type, (int) cipher_size);
return retval;
}
|
↓
|
print_oneline
|
21
|
86
|
163
|
x509/output.c
|
static void
print_oneline (gnutls_buffer_st * str, gnutls_x509_crt_t cert)
{
/* Subject. */
{
char *dn;
size_t dn_size = 0;
int err;
err = gnutls_x509_crt_get_dn (cert, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "unknown subject (%s), ", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "unknown subject (%s), ",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_x509_crt_get_dn (cert, dn, &dn_size);
if (err < 0)
addf (str, "unknown subject (%s), ", gnutls_strerror (err));
else
addf (str, "subject `%s', ", dn);
gnutls_free (dn);
}
}
}
/* Issuer. */
{
char *dn;
size_t dn_size = 0;
int err;
err = gnutls_x509_crt_get_issuer_dn (cert, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
addf (str, "unknown issuer (%s), ", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "unknown issuer (%s), ",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_x509_crt_get_issuer_dn (cert, dn, &dn_size);
if (err < 0)
addf (str, "unknown issuer (%s), ", gnutls_strerror (err));
else
addf (str, "issuer `%s', ", dn);
gnutls_free (dn);
}
}
}
/* Key algorithm and size. */
{
unsigned int bits;
const char *name = gnutls_pk_algorithm_get_name
(gnutls_x509_crt_get_pk_algorithm (cert, &bits));
if (name == NULL)
name = "Unknown";
addf (str, "%s key %d bits, ", name, bits);
}
/* Signature Algorithm. */
{
int err;
err = gnutls_x509_crt_get_signature_algorithm (cert);
if (err < 0)
addf (str, "unknown signature algorithm (%s), ", gnutls_strerror (err));
else
{
const char *name = gnutls_sign_algorithm_get_name (err);
if (name == NULL)
name = _("unknown");
if (err == GNUTLS_SIGN_RSA_MD5 || err == GNUTLS_SIGN_RSA_MD2)
addf (str, _("signed using %s (broken!), "), name);
else
addf (str, _("signed using %s, "), name);
}
}
/* Validity. */
{
time_t tim;
tim = gnutls_x509_crt_get_activation_time (cert);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
addf (str, "unknown activation (%ld), ", (unsigned long) tim);
else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
addf (str, "failed activation (%ld), ", (unsigned long) tim);
else
addf (str, "activated `%s', ", s);
}
tim = gnutls_x509_crt_get_expiration_time (cert);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
addf (str, "unknown expiry (%ld), ", (unsigned long) tim);
else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
addf (str, "failed expiry (%ld), ", (unsigned long) tim);
else
addf (str, "expires `%s', ", s);
}
}
{
int pathlen;
char *policyLanguage;
int err;
err = gnutls_x509_crt_get_proxy (cert, NULL,
&pathlen, &policyLanguage, NULL, NULL);
if (err == 0)
{
addf (str, "proxy certificate (policy=");
if (strcmp (policyLanguage, "1.3.6.1.5.5.7.21.1") == 0)
addf (str, "id-ppl-inheritALL");
else if (strcmp (policyLanguage, "1.3.6.1.5.5.7.21.2") == 0)
addf (str, "id-ppl-independent");
else
addf (str, "%s", policyLanguage);
if (pathlen >= 0)
addf (str, ", pathlen=%d), ", pathlen);
else
addf (str, "), ");
gnutls_free (policyLanguage);
}
}
{
char buffer[20];
size_t size = sizeof (buffer);
int err;
err = gnutls_x509_crt_get_fingerprint (cert, GNUTLS_DIG_SHA1,
buffer, &size);
if (err < 0)
{
addf (str, "unknown fingerprint (%s)", gnutls_strerror (err));
}
else
{
addf (str, "SHA-1 fingerprint `");
_gnutls_buffer_hexprint (str, buffer, size);
adds (str, "'");
}
}
}
|
↓
|
gnutls_x509_privkey_import
|
21
|
59
|
131
|
x509/privkey.c
|
int
gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
const gnutls_datum_t * data,
gnutls_x509_crt_fmt_t format)
{
int result = 0, need_free = 0;
gnutls_datum_t _data;
if (key == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
_data.data = data->data;
_data.size = data->size;
key->pk_algorithm = GNUTLS_PK_UNKNOWN;
/* If the Certificate is in PEM format then decode it
*/
if (format == GNUTLS_X509_FMT_PEM)
{
opaque *out;
/* Try the first header */
result =
_gnutls_fbase64_decode (PEM_KEY_RSA, data->data, data->size, &out);
if (result >= 0)
key->pk_algorithm = GNUTLS_PK_RSA;
if (result == GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR)
{
/* try for the second header */
result =
_gnutls_fbase64_decode (PEM_KEY_DSA, data->data, data->size,
&out);
if (result >= 0)
key->pk_algorithm = GNUTLS_PK_DSA;
if (result == GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR)
{
/* try for the second header */
result =
_gnutls_fbase64_decode (PEM_KEY_ECC, data->data, data->size,
&out);
if (result >= 0)
key->pk_algorithm = GNUTLS_PK_EC;
}
}
if (result < 0)
{
gnutls_assert ();
goto failover;
}
_data.data = out;
_data.size = result;
need_free = 1;
}
if (key->pk_algorithm == GNUTLS_PK_RSA)
{
key->key = _gnutls_privkey_decode_pkcs1_rsa_key (&_data, key);
if (key->key == NULL)
gnutls_assert ();
}
else if (key->pk_algorithm == GNUTLS_PK_DSA)
{
key->key = decode_dsa_key (&_data, key);
if (key->key == NULL)
gnutls_assert ();
}
else if (key->pk_algorithm == GNUTLS_PK_EC)
{
key->key = _gnutls_privkey_decode_ecc_key (&_data, key);
if (key->key == NULL)
gnutls_assert ();
}
else
{
/* Try decoding with both, and accept the one that
* succeeds.
*/
key->pk_algorithm = GNUTLS_PK_RSA;
key->key = _gnutls_privkey_decode_pkcs1_rsa_key (&_data, key);
if (key->key == NULL)
{
key->pk_algorithm = GNUTLS_PK_DSA;
key->key = decode_dsa_key (&_data, key);
if (key->key == NULL)
gnutls_assert ();
}
}
if (key->key == NULL)
{
gnutls_assert ();
result = GNUTLS_E_ASN1_DER_ERROR;
goto failover;
}
if (need_free)
_gnutls_free_datum (&_data);
/* The key has now been decoded.
*/
return 0;
failover:
/* Try PKCS #8 */
#ifdef ENABLE_PKI
if (result == GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR)
{
_gnutls_debug_log ("Falling back to PKCS #8 key decoding\n");
result = gnutls_x509_privkey_import_pkcs8 (key, data, format,
NULL, GNUTLS_PKCS_PLAIN);
}
#endif
if (need_free)
_gnutls_free_datum (&_data);
return result;
}
|
↓
|
record_add_to_buffers
|
20
|
55
|
163
|
gnutls_record.c
|
static int
record_add_to_buffers (gnutls_session_t session,
struct tls_record_st *recv, content_type_t type,
gnutls_handshake_description_t htype,
uint64* seq,
mbuffer_st* bufel)
{
int ret;
if ((recv->type == type)
&& (type == GNUTLS_APPLICATION_DATA ||
type == GNUTLS_CHANGE_CIPHER_SPEC ||
type == GNUTLS_HANDSHAKE))
{
_gnutls_record_buffer_put (session, type, seq, bufel);
/* if we received application data as expected then we
* deactivate the async timer */
_dtls_async_timer_delete(session);
}
else
{
/* if the expected type is different than the received
*/
switch (recv->type)
{
case GNUTLS_ALERT:
if (bufel->msg.size < 2)
{
ret = gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
goto cleanup;
}
_gnutls_record_log
("REC[%p]: Alert[%d|%d] - %s - was received\n", session,
bufel->msg.data[0], bufel->msg.data[1], gnutls_alert_get_name ((int) bufel->msg.data[1]));
session->internals.last_alert = bufel->msg.data[1];
/* if close notify is received and
* the alert is not fatal
*/
if (bufel->msg.data[1] == GNUTLS_A_CLOSE_NOTIFY && bufel->msg.data[0] != GNUTLS_AL_FATAL)
{
/* If we have been expecting for an alert do
*/
session->internals.read_eof = 1;
ret = GNUTLS_E_INT_RET_0; /* EOF */
goto cleanup;
}
else
{
/* if the alert is FATAL or WARNING
* return the apropriate message
*/
gnutls_assert ();
ret = GNUTLS_E_WARNING_ALERT_RECEIVED;
if (bufel->msg.data[0] == GNUTLS_AL_FATAL)
{
session_unresumable (session);
session_invalidate (session);
ret = gnutls_assert_val(GNUTLS_E_FATAL_ALERT_RECEIVED);
}
goto cleanup;
}
break;
case GNUTLS_CHANGE_CIPHER_SPEC:
if (!(IS_DTLS(session)))
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
_gnutls_record_buffer_put (session, type, seq, bufel);
break;
case GNUTLS_APPLICATION_DATA:
if (session->internals.initial_negotiation_completed == 0)
{
ret = gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
goto cleanup;
}
/* even if data is unexpected put it into the buffer */
if ((ret =
_gnutls_record_buffer_put (session, recv->type, seq,
bufel)) < 0)
{
gnutls_assert ();
goto cleanup;
}
/* the got_application data is only returned
* if expecting client hello (for rehandshake
* reasons). Otherwise it is an unexpected packet
*/
if (type == GNUTLS_ALERT || (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO
&& type == GNUTLS_HANDSHAKE))
{
return gnutls_assert_val(GNUTLS_E_GOT_APPLICATION_DATA);
}
else
{
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
}
break;
case GNUTLS_HANDSHAKE:
/* In DTLS we might receive a handshake replay from the peer to indicate
* the our last TLS handshake messages were not received.
*/
if (_dtls_is_async(session) && _dtls_async_timer_active(session))
{
ret = _dtls_retransmit(session);
goto cleanup;
}
/* This is legal if HELLO_REQUEST is received - and we are a client.
* If we are a server, a client may initiate a renegotiation at any time.
*/
if (session->security_parameters.entity == GNUTLS_SERVER)
{
gnutls_assert ();
ret =
_gnutls_record_buffer_put (session, recv->type, seq, bufel);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
return GNUTLS_E_REHANDSHAKE;
}
/* If we are already in a handshake then a Hello
* Request is illegal. But here we don't really care
* since this message will never make it up here.
*/
/* So we accept it */
ret = _gnutls_recv_hello_request (session, bufel->msg.data, bufel->msg.size);
goto cleanup;
break;
default:
_gnutls_record_log
("REC[%p]: Received Unknown packet %d expecting %d\n",
session, recv->type, type);
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto cleanup;
}
}
return 0;
cleanup:
_mbuffer_xfree(&bufel);
return ret;
}
|
↓
|
_gnutls_x509_parse_dn_oid
|
20
|
82
|
166
|
x509/dn.c
|
int
_gnutls_x509_parse_dn_oid (ASN1_TYPE asn1_struct,
const char *asn1_rdn_name,
const char *given_oid, int indx,
unsigned int raw_flag,
void *buf, size_t * sizeof_buf)
{
int k2, k1, result;
char tmpbuffer1[ASN1_MAX_NAME_SIZE];
char tmpbuffer2[ASN1_MAX_NAME_SIZE];
char tmpbuffer3[ASN1_MAX_NAME_SIZE];
opaque value[256];
char oid[MAX_OID_SIZE];
int len, printable;
int i = 0;
char *cbuf = buf;
if (cbuf == NULL)
*sizeof_buf = 0;
else
cbuf[0] = 0;
k1 = 0;
do
{
k1++;
/* create a string like "tbsCertList.issuer.rdnSequence.?1"
*/
if (asn1_rdn_name[0] != 0)
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", asn1_rdn_name,
k1);
else
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
gnutls_assert ();
break;
}
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
k2 = 0;
do
{ /* Move to the attibute type and values
*/
k2++;
if (tmpbuffer1[0] != 0)
snprintf (tmpbuffer2, sizeof (tmpbuffer2), "%s.?%u", tmpbuffer1,
k2);
else
snprintf (tmpbuffer2, sizeof (tmpbuffer2), "?%u", k2);
/* Try to read the RelativeDistinguishedName attributes.
*/
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer2, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
break;
}
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Read the OID
*/
_gnutls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
_gnutls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
len = sizeof (oid) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
break;
else if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (strcmp (oid, given_oid) == 0 && indx == i++)
{ /* Found the OID */
/* Read the Value
*/
_gnutls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
_gnutls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value");
len = *sizeof_buf;
result = asn1_read_value (asn1_struct, tmpbuffer3, buf, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
if (result == ASN1_MEM_ERROR)
*sizeof_buf = len;
result = _gnutls_asn2err (result);
goto cleanup;
}
if (raw_flag != 0)
{
if ((unsigned) len > *sizeof_buf)
{
*sizeof_buf = len;
result = GNUTLS_E_SHORT_MEMORY_BUFFER;
goto cleanup;
}
*sizeof_buf = len;
return 0;
}
else
{ /* parse data. raw_flag == 0 */
printable = _gnutls_x509_oid_data_printable (oid);
if (printable == 1)
result =
_gnutls_x509_oid_data2string (oid, buf, len,
cbuf, sizeof_buf);
else
result =
_gnutls_x509_data2hex (buf, len, cbuf, sizeof_buf);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
return 0;
} /* raw_flag == 0 */
}
}
while (1);
}
while (1);
gnutls_assert ();
result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
cleanup:
return result;
}
|
↓
|
_gnutls_srp_pwd_read_entry
|
20
|
69
|
148
|
auth/srp_passwd.c
|
int
_gnutls_srp_pwd_read_entry (gnutls_session_t state, char *username,
SRP_PWD_ENTRY ** _entry)
{
gnutls_srp_server_credentials_t cred;
FILE *fd;
char line[2 * 1024];
unsigned i, len;
int ret;
int idx, last_idx;
SRP_PWD_ENTRY *entry;
*_entry = gnutls_calloc (1, sizeof (SRP_PWD_ENTRY));
if (*_entry == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
entry = *_entry;
cred = (gnutls_srp_server_credentials_t)
_gnutls_get_cred (state->key, GNUTLS_CRD_SRP, NULL);
if (cred == NULL)
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* if the callback which sends the parameters is
* set, use it.
*/
if (cred->pwd_callback != NULL)
{
ret = cred->pwd_callback (state, username, &entry->salt,
&entry->v, &entry->g, &entry->n);
if (ret == 1)
{ /* the user does not exist */
if (entry->g.size != 0 && entry->n.size != 0)
{
ret = _randomize_pwd_entry (entry);
if (ret < 0)
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return ret;
}
return 0;
}
else
{
gnutls_assert ();
ret = -1; /* error in the callback */
}
}
if (ret < 0)
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return GNUTLS_E_SRP_PWD_ERROR;
}
return 0;
}
/* The callback was not set. Proceed.
*/
if (cred->password_file == NULL)
{
gnutls_assert ();
return GNUTLS_E_SRP_PWD_ERROR;
}
/* Open the selected password file.
*/
fd = fopen (cred->password_file, "r");
if (fd == NULL)
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return GNUTLS_E_SRP_PWD_ERROR;
}
last_idx = 1; /* a default value */
len = strlen (username);
while (fgets (line, sizeof (line), fd) != NULL)
{
/* move to first ':' */
i = 0;
while ((line[i] != ':') && (line[i] != '\0') && (i < sizeof (line)))
{
i++;
}
if (strncmp (username, line, MAX (i, len)) == 0)
{
if ((idx = pwd_put_values (entry, line)) >= 0)
{
/* Keep the last index in memory, so we can retrieve fake parameters (g,n)
* when the user does not exist.
*/
/* XXX: last_idx will not be read as both if block branches return. */
last_idx = idx;
if (pwd_read_conf (cred->password_conf_file, entry, idx) == 0)
{
return 0;
}
else
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return GNUTLS_E_SRP_PWD_ERROR;
}
}
else
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return GNUTLS_E_SRP_PWD_ERROR;
}
}
}
/* user was not found. Fake him. Actually read the g,n values from
* the last index found and randomize the entry.
*/
if (pwd_read_conf (cred->password_conf_file, entry, last_idx) == 0)
{
ret = _randomize_pwd_entry (entry);
if (ret < 0)
{
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return ret;
}
return 0;
}
gnutls_assert ();
_gnutls_srp_entry_free (entry);
return GNUTLS_E_SRP_PWD_ERROR;
}
|
↓
|
read_signature
|
20
|
68
|
89
|
opencdk/read-packet.c
|
static cdk_error_t
read_signature (cdk_stream_t inp, size_t pktlen, cdk_pkt_signature_t sig)
{
size_t nbytes;
size_t i, size, nsig;
cdk_error_t rc;
if (!inp || !sig)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_signature: %d octets\n", (int) pktlen);
if (pktlen < 16)
return CDK_Inv_Packet;
sig->version = cdk_stream_getc (inp);
if (sig->version < 2 || sig->version > 4)
return CDK_Inv_Packet_Ver;
sig->flags.exportable = 1;
sig->flags.revocable = 1;
if (sig->version < 4)
{
if (cdk_stream_getc (inp) != 5)
return CDK_Inv_Packet;
sig->sig_class = cdk_stream_getc (inp);
sig->timestamp = read_32 (inp);
sig->keyid[0] = read_32 (inp);
sig->keyid[1] = read_32 (inp);
sig->pubkey_algo = _pgp_pub_algo_to_cdk (cdk_stream_getc (inp));
sig->digest_algo = _pgp_hash_algo_to_gnutls (cdk_stream_getc (inp));
sig->digest_start[0] = cdk_stream_getc (inp);
sig->digest_start[1] = cdk_stream_getc (inp);
nsig = cdk_pk_get_nsig (sig->pubkey_algo);
if (!nsig)
return CDK_Inv_Algo;
for (i = 0; i < nsig; i++)
{
rc = read_mpi (inp, &sig->mpi[i], 0);
if (rc)
return rc;
}
}
else
{
sig->sig_class = cdk_stream_getc (inp);
sig->pubkey_algo = _pgp_pub_algo_to_cdk (cdk_stream_getc (inp));
sig->digest_algo = _pgp_hash_algo_to_gnutls (cdk_stream_getc (inp));
sig->hashed_size = read_16 (inp);
size = sig->hashed_size;
sig->hashed = NULL;
while (size > 0)
{
rc = read_subpkt (inp, &sig->hashed, &nbytes);
if (rc)
return rc;
size -= nbytes;
}
sig->unhashed_size = read_16 (inp);
size = sig->unhashed_size;
sig->unhashed = NULL;
while (size > 0)
{
rc = read_subpkt (inp, &sig->unhashed, &nbytes);
if (rc)
return rc;
size -= nbytes;
}
rc = parse_sig_subpackets (sig);
if (rc)
return rc;
sig->digest_start[0] = cdk_stream_getc (inp);
sig->digest_start[1] = cdk_stream_getc (inp);
nsig = cdk_pk_get_nsig (sig->pubkey_algo);
if (!nsig)
return CDK_Inv_Algo;
for (i = 0; i < nsig; i++)
{
rc = read_mpi (inp, &sig->mpi[i], 0);
if (rc)
return rc;
}
}
return 0;
}
|
↓
|
_gnutls_verify_crl2
|
20
|
54
|
109
|
x509/verify.c
|
static int
_gnutls_verify_crl2 (gnutls_x509_crl_t crl,
const gnutls_x509_crt_t * trusted_cas,
int tcas_size, unsigned int flags, unsigned int *output)
{
/* CRL is ignored for now */
gnutls_datum_t crl_signed_data = { NULL, 0 };
gnutls_datum_t crl_signature = { NULL, 0 };
gnutls_x509_crt_t issuer;
int result, hash_algo;
if (output)
*output = 0;
if (tcas_size >= 1)
issuer = find_crl_issuer (crl, trusted_cas, tcas_size);
else
{
gnutls_assert ();
if (output)
*output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
return 0;
}
/* issuer is not in trusted certificate
* authorities.
*/
if (issuer == NULL)
{
gnutls_assert ();
if (output)
*output |= GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_INVALID;
return 0;
}
if (!(flags & GNUTLS_VERIFY_DISABLE_CA_SIGN))
{
if (gnutls_x509_crt_get_ca_status (issuer, NULL) != 1)
{
gnutls_assert ();
if (output)
*output |= GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_INVALID;
return 0;
}
}
result =
_gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_x509_get_signature (crl->crl, "signature", &crl_signature);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_x509_get_signature_algorithm(crl->crl, "signatureAlgorithm.algorithm");
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
hash_algo = _gnutls_sign_get_hash_algorithm(result);
result =
_gnutls_x509_verify_data (hash_algo, &crl_signed_data, &crl_signature,
issuer);
if (result == GNUTLS_E_PK_SIG_VERIFY_FAILED)
{
gnutls_assert ();
/* error. ignore it */
if (output)
*output |= GNUTLS_CERT_INVALID;
result = 0;
}
else if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
{
int sigalg;
sigalg = gnutls_x509_crl_get_signature_algorithm (crl);
if (((sigalg == GNUTLS_SIGN_RSA_MD2) &&
!(flags & GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2)) ||
((sigalg == GNUTLS_SIGN_RSA_MD5) &&
!(flags & GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5)))
{
if (output)
*output |= GNUTLS_CERT_INSECURE_ALGORITHM | GNUTLS_CERT_INVALID;
result = 0;
}
}
cleanup:
_gnutls_free_datum (&crl_signed_data);
_gnutls_free_datum (&crl_signature);
return result;
}
|
↓
|
decode_pkcs8_key
|
20
|
52
|
126
|
x509/privkey_pkcs8.c
|
static int
decode_pkcs8_key (const gnutls_datum_t * raw_key,
const char *password, gnutls_x509_privkey_t pkey)
{
int result, len;
char enc_oid[64];
gnutls_datum_t tmp;
ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY, pkcs8_asn = ASN1_TYPE_EMPTY;
int params_start, params_end, params_len;
struct pbkdf2_params kdf_params;
struct pbe_enc_params enc_params;
schema_id schema;
if ((result =
asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-8-EncryptedPrivateKeyInfo",
&pkcs8_asn)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
result = asn1_der_decoding (&pkcs8_asn, raw_key->data, raw_key->size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Check the encryption schema OID
*/
len = sizeof (enc_oid);
result =
asn1_read_value (pkcs8_asn, "encryptionAlgorithm.algorithm",
enc_oid, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
goto error;
}
if ((result = check_schema (enc_oid)) < 0)
{
gnutls_assert ();
goto error;
}
schema = result;
/* Get the DER encoding of the parameters.
*/
result =
asn1_der_decoding_startEnd (pkcs8_asn, raw_key->data,
raw_key->size,
"encryptionAlgorithm.parameters",
¶ms_start, ¶ms_end);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
params_len = params_end - params_start + 1;
result =
read_pkcs_schema_params (&schema, password,
&raw_key->data[params_start],
params_len, &kdf_params, &enc_params);
if (result < 0)
{
gnutls_assert ();
goto error;
}
/* Parameters have been decoded. Now
* decrypt the EncryptedData.
*/
result =
decrypt_data (schema, pkcs8_asn, "encryptedData", password,
&kdf_params, &enc_params, &tmp);
if (result < 0)
{
gnutls_assert ();
goto error;
}
asn1_delete_structure (&pkcs8_asn);
result = decode_private_key_info (&tmp, pkey);
_gnutls_free_datum (&tmp);
if (result < 0)
{
/* We've gotten this far. In the real world it's almost certain
* that we're dealing with a good file, but wrong password.
* Sadly like 90% of random data is somehow valid DER for the
* a first small number of bytes, so no easy way to guarantee. */
if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND ||
result == GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND ||
result == GNUTLS_E_ASN1_DER_ERROR ||
result == GNUTLS_E_ASN1_VALUE_NOT_FOUND ||
result == GNUTLS_E_ASN1_GENERIC_ERROR ||
result == GNUTLS_E_ASN1_VALUE_NOT_VALID ||
result == GNUTLS_E_ASN1_TAG_ERROR ||
result == GNUTLS_E_ASN1_TAG_IMPLICIT ||
result == GNUTLS_E_ASN1_TYPE_ANY_ERROR ||
result == GNUTLS_E_ASN1_SYNTAX_ERROR ||
result == GNUTLS_E_ASN1_DER_OVERFLOW)
{
result = GNUTLS_E_DECRYPTION_FAILED;
}
gnutls_assert ();
goto error;
}
return 0;
error:
asn1_delete_structure (&pbes2_asn);
asn1_delete_structure (&pkcs8_asn);
return result;
}
|
↓
|
write_signature
|
20
|
49
|
63
|
opencdk/write-packet.c
|
static cdk_error_t
write_signature (cdk_stream_t out, cdk_pkt_signature_t sig, int old_ctb)
{
byte *buf;
size_t nbytes, size, nsig;
cdk_error_t rc;
assert (out);
assert (sig);
if (!KEY_CAN_SIGN (sig->pubkey_algo))
return CDK_Inv_Algo;
if (sig->version < 2 || sig->version > 4)
return CDK_Inv_Packet;
if (DEBUG_PKT)
_gnutls_write_log ("write_signature:\n");
nsig = cdk_pk_get_nsig (sig->pubkey_algo);
if (!nsig)
return CDK_Inv_Algo;
if (sig->version < 4)
return write_v3_sig (out, sig, nsig);
size = 10 + calc_subpktsize (sig->hashed)
+ calc_subpktsize (sig->unhashed) + calc_mpisize (sig->mpi, nsig);
rc = pkt_write_head (out, 0, size, CDK_PKT_SIGNATURE);
if (!rc)
rc = stream_putc (out, 4);
if (!rc)
rc = stream_putc (out, sig->sig_class);
if (!rc)
rc = stream_putc (out, _cdk_pub_algo_to_pgp (sig->pubkey_algo));
if (!rc)
rc = stream_putc (out, _gnutls_hash_algo_to_pgp (sig->digest_algo));
if (!rc)
rc = write_16 (out, sig->hashed_size);
if (!rc)
{
buf = _cdk_subpkt_get_array (sig->hashed, 0, &nbytes);
if (!buf)
return CDK_Out_Of_Core;
rc = stream_write (out, buf, nbytes);
cdk_free (buf);
}
if (!rc)
rc = write_16 (out, sig->unhashed_size);
if (!rc)
{
buf = _cdk_subpkt_get_array (sig->unhashed, 0, &nbytes);
if (!buf)
return CDK_Out_Of_Core;
rc = stream_write (out, buf, nbytes);
cdk_free (buf);
}
if (!rc)
rc = stream_putc (out, sig->digest_start[0]);
if (!rc)
rc = stream_putc (out, sig->digest_start[1]);
if (!rc)
rc = write_mpibuf (out, sig->mpi, nsig);
return rc;
}
|
↓
|
wrap_nettle_pk_verify_params
|
19
|
79
|
153
|
nettle/pk.c
|
static int
wrap_nettle_pk_verify_params (gnutls_pk_algorithm_t algo,
const gnutls_pk_params_st * params)
{
int ret;
switch (algo)
{
case GNUTLS_PK_RSA:
{
bigint_t t1 = NULL, t2 = NULL;
if (params->params_nr != RSA_PRIVATE_PARAMS)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
t1 = _gnutls_mpi_new (256);
if (t1 == NULL)
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
_gnutls_mpi_mulm (t1, params->params[RSA_PRIME1], params->params[RSA_PRIME2], params->params[RSA_MODULUS]);
if (_gnutls_mpi_cmp_ui(t1, 0) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto rsa_cleanup;
}
mpz_invert (TOMPZ(t1), TOMPZ (params->params[RSA_PRIME2]), TOMPZ (params->params[RSA_PRIME1]));
if (_gnutls_mpi_cmp(t1, params->params[RSA_COEF]) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto rsa_cleanup;
}
/* [RSA_PRIME1] = d % p-1, [RSA_PRIME2] = d % q-1 */
_gnutls_mpi_sub_ui (t1, params->params[RSA_PRIME1], 1);
t2 = _gnutls_mpi_mod (params->params[RSA_PRIV], t1);
if (t2 == NULL)
{
ret = gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
goto rsa_cleanup;
}
if (_gnutls_mpi_cmp(params->params[RSA_E1], t2) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto rsa_cleanup;
}
_gnutls_mpi_sub_ui (t1, params->params[RSA_PRIME2], 1);
_gnutls_mpi_release(&t2);
t2 = _gnutls_mpi_mod (params->params[RSA_PRIV], t1);
if (t2 == NULL)
{
ret = gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
goto rsa_cleanup;
}
if (_gnutls_mpi_cmp(params->params[RSA_E2], t2) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto rsa_cleanup;
}
ret = 0;
rsa_cleanup:
_gnutls_mpi_release(&t1);
_gnutls_mpi_release(&t2);
}
break;
case GNUTLS_PK_DSA:
{
bigint_t t1 = NULL;
if (params->params_nr != DSA_PRIVATE_PARAMS)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
t1 = _gnutls_mpi_new (256);
if (t1 == NULL)
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
_gnutls_mpi_powm (t1, params->params[DSA_G], params->params[DSA_X], params->params[DSA_P]);
if (_gnutls_mpi_cmp(t1, params->params[DSA_Y]) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto dsa_cleanup;
}
ret = 0;
dsa_cleanup:
_gnutls_mpi_release(&t1);
}
break;
case GNUTLS_PK_EC:
{
int curve = params->flags;
ecc_key ecc_priv;
ecc_point *R;
ecc_point zero;
if (params->params_nr != ECC_PRIVATE_PARAMS)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
if (is_supported_curve(curve) == 0)
return gnutls_assert_val(GNUTLS_E_ECC_UNSUPPORTED_CURVE);
_ecc_params_to_privkey(params, &ecc_priv);
R = ecc_new_point();
/* verify that x,y lie on the curve */
ret = ecc_projective_check_point(&ecc_priv.pubkey, TOMPZ(params->params[ECC_B]), params->params[ECC_PRIME]);
if (ret != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto ecc_cleanup;
}
memcpy(&zero.x, ecc_priv.Gx, sizeof(mpz_t));
memcpy(&zero.y, ecc_priv.Gy, sizeof(mpz_t));
memcpy(&zero.z, ecc_priv.pubkey.z, sizeof(mpz_t)); /* z = 1 */
/* verify that k*(Gx,Gy)=(x,y) */
ret = ecc_mulmod(ecc_priv.k, &zero, R, TOMPZ(params->params[ECC_A]), TOMPZ(params->params[ECC_PRIME]), 1);
if (ret != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto ecc_cleanup;
}
if (mpz_cmp(ecc_priv.pubkey.x, R->x) != 0 || mpz_cmp(ecc_priv.pubkey.y, R->y) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
goto ecc_cleanup;
}
ret = 0;
ecc_cleanup:
_ecc_params_clear(&ecc_priv);
ecc_del_point(R);
}
break;
default:
ret = gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
}
return ret;
}
|
↓
|
gnutls_x509_crt_list_import
|
19
|
67
|
131
|
x509/x509.c
|
int
gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
unsigned int *cert_max,
const gnutls_datum_t * data,
gnutls_x509_crt_fmt_t format, unsigned int flags)
{
int size;
const char *ptr;
gnutls_datum_t tmp;
int ret, nocopy = 0;
unsigned int count = 0, j;
if (format == GNUTLS_X509_FMT_DER)
{
if (*cert_max < 1)
{
*cert_max = 1;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
count = 1; /* import only the first one */
ret = gnutls_x509_crt_init (&certs[0]);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
ret = gnutls_x509_crt_import (certs[0], data, format);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
*cert_max = 1;
return 1;
}
/* move to the certificate
*/
ptr = memmem (data->data, data->size,
PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
if (ptr == NULL)
ptr = memmem (data->data, data->size,
PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
if (ptr == NULL)
return gnutls_assert_val(GNUTLS_E_NO_CERTIFICATE_FOUND);
count = 0;
do
{
if (count >= *cert_max)
{
if (!(flags & GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED))
break;
else
nocopy = 1;
}
if (!nocopy)
{
ret = gnutls_x509_crt_init (&certs[count]);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
tmp.data = (void *) ptr;
tmp.size = data->size - (ptr - (char *) data->data);
ret =
gnutls_x509_crt_import (certs[count], &tmp, GNUTLS_X509_FMT_PEM);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
}
/* now we move ptr after the pem header
*/
ptr++;
/* find the next certificate (if any)
*/
size = data->size - (ptr - (char *) data->data);
if (size > 0)
{
char *ptr2;
ptr2 = memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
if (ptr2 == NULL)
ptr2 = memmem (ptr, size, PEM_CERT_SEP2,
sizeof (PEM_CERT_SEP2) - 1);
ptr = ptr2;
}
else
ptr = NULL;
count++;
}
while (ptr != NULL);
*cert_max = count;
if (flags & GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED)
{
ret = check_if_sorted(certs, *cert_max);
if (ret < 0)
{
gnutls_assert();
goto error;
}
}
if (nocopy == 0)
return count;
else
return GNUTLS_E_SHORT_MEMORY_BUFFER;
error:
for (j = 0; j < count; j++)
gnutls_x509_crt_deinit (certs[j]);
return ret;
}
|
↓
|
cdk_pk_check_sigs
|
19
|
48
|
87
|
opencdk/sig-check.c
|
cdk_error_t
cdk_pk_check_sigs (cdk_kbnode_t key, cdk_keydb_hd_t keydb, int *r_status)
{
cdk_pkt_signature_t sig;
cdk_kbnode_t node;
cdk_error_t rc;
u32 keyid;
int key_status, is_selfsig = 0;
struct verify_uid *uid_list = NULL;
char *uid_name;
if (!key || !r_status)
{
gnutls_assert ();
return CDK_Inv_Value;
}
*r_status = 0;
node = cdk_kbnode_find (key, CDK_PKT_PUBLIC_KEY);
if (!node)
{
gnutls_assert ();
return CDK_Error_No_Key;
}
key_status = 0;
/* Continue with the signature check but adjust the
key status flags accordingly. */
if (node->pkt->pkt.public_key->is_revoked)
key_status |= CDK_KEY_REVOKED;
if (node->pkt->pkt.public_key->has_expired)
key_status |= CDK_KEY_EXPIRED;
rc = 0;
keyid = cdk_pk_get_keyid (node->pkt->pkt.public_key, NULL);
for (node = key; node; node = node->next)
{
if (node->pkt->pkttype != CDK_PKT_SIGNATURE)
continue;
sig = node->pkt->pkt.signature;
rc = _cdk_pk_check_sig (keydb, key, node, &is_selfsig, &uid_name);
if (rc && rc != CDK_Error_No_Key)
{
/* It might be possible that a single signature has been
corrupted, thus we do not consider it a problem when
one ore more signatures are bad. But at least the self
signature has to be valid. */
if (is_selfsig)
{
key_status |= CDK_KEY_INVALID;
break;
}
}
_cdk_log_debug ("signature %s: signer %08X keyid %08X\n",
rc == CDK_Bad_Sig ? "BAD" : "good",
(unsigned int) sig->keyid[1], (unsigned int) keyid);
if (IS_UID_SIG (sig) && uid_name != NULL)
{
/* add every uid in the uid list. Only consider valid:
* - verification was ok
* - not a selfsig
*/
rc =
uid_list_add_sig (&uid_list, uid_name,
(rc == CDK_Success && is_selfsig == 0) ? 1 : 0);
if (rc != CDK_Success)
{
gnutls_assert ();
goto exit;
}
}
}
if (uid_list_all_signed (uid_list) == 0)
key_status |= CDK_KEY_NOSIGNER;
*r_status = key_status;
if (rc == CDK_Error_No_Key)
rc = 0;
exit:
uid_list_free (uid_list);
return rc;
}
|
↓
|
_gnutls_recv_client_certificate
|
19
|
32
|
91
|
gnutls_kx.c
|
int
_gnutls_recv_client_certificate (gnutls_session_t session)
{
gnutls_buffer_st buf;
int ret = 0;
int optional;
if (session->internals.auth_struct->gnutls_process_client_certificate ==
NULL)
return 0;
/* if we have not requested a certificate then just return
*/
if (session->internals.send_cert_req == 0)
{
return 0;
}
if (session->internals.send_cert_req == GNUTLS_CERT_REQUIRE)
optional = MANDATORY_PACKET;
else
optional = OPTIONAL_PACKET;
ret =
_gnutls_recv_handshake (session, GNUTLS_HANDSHAKE_CERTIFICATE_PKT,
optional, &buf);
if (ret < 0)
{
/* Handle the case of old SSL3 clients who send
* a warning alert instead of an empty certificate to indicate
* no certificate.
*/
if (optional == OPTIONAL_PACKET &&
ret == GNUTLS_E_WARNING_ALERT_RECEIVED &&
gnutls_protocol_get_version (session) == GNUTLS_SSL3 &&
gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE)
{
/* SSL3 does not send an empty certificate,
* but this alert. So we just ignore it.
*/
gnutls_assert ();
return 0;
}
/* certificate was required
*/
if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED
|| ret == GNUTLS_E_FATAL_ALERT_RECEIVED)
&& optional == MANDATORY_PACKET)
{
gnutls_assert ();
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
return ret;
}
if (ret == 0 && buf.length == 0 && optional == OPTIONAL_PACKET)
{
/* Client has not sent the certificate message.
* well I'm not sure we should accept this
* behaviour.
*/
gnutls_assert ();
ret = 0;
goto cleanup;
}
ret =
session->internals.
auth_struct->gnutls_process_client_certificate (session, buf.data,
buf.length);
if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND)
{
gnutls_assert ();
goto cleanup;
}
/* ok we should expect a certificate verify message now
*/
if (ret == GNUTLS_E_NO_CERTIFICATE_FOUND && optional == OPTIONAL_PACKET)
ret = 0;
else
session->key->certificate_requested = 1;
cleanup:
_gnutls_buffer_clear(&buf);
return ret;
}
|
↓
|
_gnutls_pkcs1_rsa_encrypt
|
18
|
88
|
155
|
gnutls_pk.c
|
int
_gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext,
const gnutls_datum_t * plaintext,
gnutls_pk_params_st * params,
unsigned btype)
{
unsigned int i, pad;
int ret;
opaque *edata, *ps;
size_t k, psize;
size_t mod_bits;
gnutls_datum_t to_encrypt, encrypted;
mod_bits = _gnutls_mpi_get_nbits (params->params[0]);
k = mod_bits / 8;
if (mod_bits % 8 != 0)
k++;
if (plaintext->size > k - 11)
{
gnutls_assert ();
return GNUTLS_E_PK_ENCRYPTION_FAILED;
}
edata = gnutls_malloc (k);
if (edata == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* EB = 00||BT||PS||00||D
* (use block type 'btype')
*/
edata[0] = 0;
edata[1] = btype;
psize = k - 3 - plaintext->size;
ps = &edata[2];
switch (btype)
{
case 2:
/* using public key */
if (params->params_nr < RSA_PUBLIC_PARAMS)
{
gnutls_assert ();
gnutls_free (edata);
return GNUTLS_E_INTERNAL_ERROR;
}
ret = _gnutls_rnd (GNUTLS_RND_RANDOM, ps, psize);
if (ret < 0)
{
gnutls_assert ();
gnutls_free (edata);
return ret;
}
for (i = 0; i < psize; i++)
while (ps[i] == 0)
{
ret = _gnutls_rnd (GNUTLS_RND_RANDOM, &ps[i], 1);
if (ret < 0)
{
gnutls_assert ();
gnutls_free (edata);
return ret;
}
}
break;
case 1:
/* using private key */
if (params->params_nr < RSA_PRIVATE_PARAMS)
{
gnutls_assert ();
gnutls_free (edata);
return GNUTLS_E_INTERNAL_ERROR;
}
for (i = 0; i < psize; i++)
ps[i] = 0xff;
break;
default:
gnutls_assert ();
gnutls_free (edata);
return GNUTLS_E_INTERNAL_ERROR;
}
ps[psize] = 0;
memcpy (&ps[psize + 1], plaintext->data, plaintext->size);
to_encrypt.data = edata;
to_encrypt.size = k;
if (btype == 2) /* encrypt */
ret =
_gnutls_pk_encrypt (GNUTLS_PK_RSA, &encrypted, &to_encrypt, params);
else /* sign */
ret =
_gnutls_pk_sign (GNUTLS_PK_RSA, &encrypted, &to_encrypt, params);
gnutls_free (edata);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
psize = encrypted.size;
if (psize < k)
{
/* padding psize */
pad = k - psize;
psize = k;
}
else if (psize == k)
{
/* pad = 0;
* no need to do anything else
*/
ciphertext->data = encrypted.data;
ciphertext->size = encrypted.size;
return 0;
}
else
{ /* psize > k !!! */
/* This is an impossible situation */
gnutls_assert ();
_gnutls_free_datum (&encrypted);
return GNUTLS_E_INTERNAL_ERROR;
}
ciphertext->data = gnutls_malloc (psize);
if (ciphertext->data == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
memcpy (&ciphertext->data[pad], encrypted.data, encrypted.size);
for (i = 0; i < pad; i++)
ciphertext->data[i] = 0;
ciphertext->size = k;
ret = 0;
cleanup:
_gnutls_free_datum (&encrypted);
return ret;
}
|
↓
|
find_obj_url
|
18
|
76
|
146
|
pkcs11.c
|
static int
find_obj_url (struct ck_function_list *module, ck_session_handle_t pks,
struct token_info *info, struct ck_info *lib_info, void *input)
{
struct url_find_data_st *find_data = input;
struct ck_attribute a[4];
struct ck_attribute *attr;
ck_object_class_t class = -1;
ck_certificate_type_t type = -1;
ck_rv_t rv;
ck_object_handle_t obj;
unsigned long count, a_vals;
int found = 0, ret;
opaque *cert_data = NULL;
char label_tmp[PKCS11_LABEL_SIZE];
if (info == NULL)
{ /* we don't support multiple calls */
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
/* do not bother reading the token if basic fields do not match
*/
if (!p11_kit_uri_match_token_info (find_data->crt->info, &info->tinfo) ||
!p11_kit_uri_match_module_info (find_data->crt->info, lib_info))
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_ID);
if (attr == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
/* search the token for the id */
cert_data = gnutls_malloc (MAX_CERT_SIZE);
if (cert_data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* Find objects with given class and type */
memcpy (a, attr, sizeof (struct ck_attribute));
a_vals = 1;
attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_CLASS);
if (attr)
{
if(attr->value && attr->value_len == sizeof (ck_object_class_t))
class = *((ck_object_class_t*)attr->value);
if (class == CKO_CERTIFICATE)
type = CKC_X_509;
memcpy (a + a_vals, attr, sizeof (struct ck_attribute));
a_vals++;
}
if (type != -1)
{
a[a_vals].type = CKA_CERTIFICATE_TYPE;
a[a_vals].value = &type;
a[a_vals].value_len = sizeof type;
a_vals++;
}
rv = pkcs11_find_objects_init (module, pks, a, a_vals);
if (rv != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("pk11: FindObjectsInit failed.\n");
ret = pkcs11_rv_to_err (rv);
goto cleanup;
}
while (pkcs11_find_objects (module, pks, &obj, 1, &count) == CKR_OK && count == 1)
{
a[0].type = CKA_VALUE;
a[0].value = cert_data;
a[0].value_len = MAX_CERT_SIZE;
a[1].type = CKA_LABEL;
a[1].value = label_tmp;
a[1].value_len = sizeof (label_tmp);
if (pkcs11_get_attribute_value (module, pks, obj, a, 2) == CKR_OK)
{
gnutls_datum_t id;
gnutls_datum_t data = { a[0].value, a[0].value_len };
gnutls_datum_t label = { a[1].value, a[1].value_len };
attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_ID);
id.data = attr->value;
id.size = attr->value_len;
if (class == CKO_PUBLIC_KEY)
{
ret =
pkcs11_obj_import_pubkey (module, pks, obj,
find_data->crt,
&id, &label,
&info->tinfo, lib_info);
}
else
{
ret =
pkcs11_obj_import (class,
find_data->crt,
&data, &id, &label,
&info->tinfo, lib_info);
}
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
found = 1;
break;
}
else
{
_gnutls_debug_log ("pk11: Skipped cert, missing attrs.\n");
}
}
if (found == 0)
{
gnutls_assert ();
ret = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
else
{
ret = 0;
}
cleanup:
gnutls_free (cert_data);
pkcs11_find_objects_final (module, pks);
return ret;
}
|
↓
|
_dtls_transmit
|
18
|
58
|
136
|
gnutls_dtls.c
|
int
_dtls_transmit (gnutls_session_t session)
{
int ret;
/* PREPARING -> SENDING state transition */
mbuffer_head_st *const send_buffer =
&session->internals.handshake_send_buffer;
mbuffer_st *cur;
gnutls_handshake_description_t last_type = 0;
time_t now = gnutls_time (0);
/* If we have already sent a flight and we are operating in a
* non blocking way, check if it is time to retransmit or just
* return.
*/
if (session->internals.dtls.flight_init != 0 && session->internals.dtls.blocking == 0)
{
/* just in case previous run was interrupted */
ret = _gnutls_io_write_flush (session);
if (session->internals.dtls.last_flight == 0)
{
/* check for ACK */
ret = _gnutls_io_check_recv(session, 0);
if (ret == GNUTLS_E_TIMEDOUT)
{
/* if no retransmission is required yet just return
*/
if (now-session->internals.dtls.handshake_start_time < session->internals.dtls.actual_retrans_timeout)
{
session->internals.dtls.handshake_last_call = now;
goto nb_timeout;
}
}
else /* received ack */
{
ret = 0;
goto cleanup;
}
}
else
return ret;
}
do
{
if (now-session->internals.dtls.handshake_start_time >= session->internals.dtls.total_timeout/1000)
{
ret = gnutls_assert_val(GNUTLS_E_TIMEDOUT);
goto cleanup;
}
_gnutls_dtls_log ("DTLS[%p]: %sstart of flight transmission.\n", session, (session->internals.dtls.flight_init == 0)?"":"re-");
for (cur = send_buffer->head;
cur != NULL; cur = cur->next)
{
transmit_message (session, cur);
last_type = cur->htype;
}
if (session->internals.dtls.flight_init == 0)
{
session->internals.dtls.flight_init = 1;
session->internals.dtls.handshake_last_call = now;
session->internals.dtls.actual_retrans_timeout = session->internals.dtls.retrans_timeout;
if (last_type == GNUTLS_HANDSHAKE_FINISHED && _dtls_is_async(session))
{
/* we cannot do anything here. We just return 0 and
* if a retransmission occurs because peer didn't receive it
* we rely on the record layer calling this function again.
*/
session->internals.dtls.last_flight = 1;
}
else
session->internals.dtls.last_flight = 0;
}
ret = _gnutls_io_write_flush (session);
if (ret < 0)
return gnutls_assert_val(ret);
/* last message in handshake -> no ack */
if (session->internals.dtls.last_flight != 0)
{
/* we cannot do anything here. We just return 0 and
* if a retransmission occurs because peer didn't receive it
* we rely on the record layer calling this function again.
*/
return 0;
}
else /* all other messages -> implicit ack (receive of next flight) */
{
if (session->internals.dtls.blocking != 0)
ret = _gnutls_io_check_recv(session, session->internals.dtls.actual_retrans_timeout);
else
{
ret = _gnutls_io_check_recv(session, 0);
if (ret == GNUTLS_E_TIMEDOUT)
{
UPDATE_TIMER;
goto nb_timeout;
}
}
}
UPDATE_TIMER;
now = gnutls_time (0);
} while(ret == GNUTLS_E_TIMEDOUT);
if (ret < 0)
{
ret = gnutls_assert_val(ret);
goto cleanup;
}
ret = 0;
cleanup:
_gnutls_dtls_log ("DTLS[%p]: End of flight transmission.\n", session);
session->internals.dtls.flight_init = 0;
drop_usage_count(session, send_buffer);
_mbuffer_head_clear(send_buffer);
/* SENDING -> WAITING state transition */
return ret;
nb_timeout:
return GNUTLS_E_AGAIN;
}
|
↓
|
print_oneline
|
18
|
57
|
106
|
openpgp/output.c
|
static void
print_oneline (gnutls_buffer_st * str, gnutls_openpgp_crt_t cert)
{
int err, i;
i = 0;
do
{
char *dn;
size_t dn_size = 0;
err = gnutls_openpgp_crt_get_name (cert, i, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER
&& err != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
&& err != GNUTLS_E_OPENPGP_UID_REVOKED)
addf (str, "unknown name (%s), ", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "unknown name (%s), ",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_openpgp_crt_get_name (cert, i, dn, &dn_size);
if (err < 0 && err != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE &&
err != GNUTLS_E_OPENPGP_UID_REVOKED)
addf (str, "unknown name (%s), ", gnutls_strerror (err));
else if (err >= 0)
addf (str, _("name[%d]: %s, "), i, dn);
else if (err == GNUTLS_E_OPENPGP_UID_REVOKED)
addf (str, _("revoked name[%d]: %s, "), i, dn);
gnutls_free (dn);
}
}
i++;
}
while (err >= 0);
{
char fpr[128];
size_t fpr_size = sizeof (fpr);
int err;
err = gnutls_openpgp_crt_get_fingerprint (cert, fpr, &fpr_size);
if (err < 0)
addf (str, "error: get_fingerprint: %s\n", gnutls_strerror (err));
else
{
adds (str, _("fingerprint: "));
_gnutls_buffer_hexprint (str, fpr, fpr_size);
addf (str, ", ");
}
}
{
time_t tim;
tim = gnutls_openpgp_crt_get_creation_time (cert);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld), ", (unsigned long) tim);
else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
addf (str, "error: strftime (%ld), ", (unsigned long) tim);
else
addf (str, _("created: %s, "), s);
}
tim = gnutls_openpgp_crt_get_expiration_time (cert);
{
char s[42];
size_t max = sizeof (s);
struct tm t;
if (tim == 0)
adds (str, _("never expires, "));
else
{
if (gmtime_r (&tim, &t) == NULL)
addf (str, "error: gmtime_r (%ld), ", (unsigned long) tim);
else if (strftime (s, max, "%Y-%m-%d %H:%M:%S UTC", &t) == 0)
addf (str, "error: strftime (%ld), ", (unsigned long) tim);
else
addf (str, _("expires: %s, "), s);
}
}
}
{
unsigned int bits = 0;
gnutls_pk_algorithm_t algo =
gnutls_openpgp_crt_get_pk_algorithm (cert, &bits);
const char *algostr = gnutls_pk_algorithm_get_name (algo);
if (algostr)
addf (str, _("key algorithm %s (%d bits)"), algostr, bits);
else
addf (str, _("unknown key algorithm (%d)"), algo);
}
}
|
↓
|
_gnutls_x509_verify_certificate
|
18
|
50
|
126
|
x509/verify.c
|
unsigned int
_gnutls_x509_verify_certificate (const gnutls_x509_crt_t * certificate_list,
int clist_size,
const gnutls_x509_crt_t * trusted_cas,
int tcas_size,
unsigned int flags,
gnutls_verify_output_function func)
{
int i = 0, ret;
unsigned int status = 0, output;
time_t now = gnutls_time (0);
gnutls_x509_crt_t issuer = NULL;
if (clist_size > 1)
{
/* Check if the last certificate in the path is self signed.
* In that case ignore it (a certificate is trusted only if it
* leads to a trusted party by us, not the server's).
*
* This prevents from verifying self signed certificates against
* themselves. This (although not bad) caused verification
* failures on some root self signed certificates that use the
* MD2 algorithm.
*/
if (gnutls_x509_crt_check_issuer (certificate_list[clist_size - 1],
certificate_list[clist_size - 1]) > 0)
{
clist_size--;
}
}
/* We want to shorten the chain by removing the cert that matches
* one of the certs we trust and all the certs after that i.e. if
* cert chain is A signed-by B signed-by C signed-by D (signed-by
* self-signed E but already removed above), and we trust B, remove
* B, C and D. */
if (!(flags & GNUTLS_VERIFY_DO_NOT_ALLOW_SAME))
i = 0; /* also replace the first one */
else
i = 1; /* do not replace the first one */
for (; i < clist_size; i++)
{
int j;
for (j = 0; j < tcas_size; j++)
{
if (check_if_same_cert (certificate_list[i], trusted_cas[j]) == 0)
{
/* explicity time check for trusted CA that we remove from
* list. GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS
*/
if (!(flags & GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS)
&& !(flags & GNUTLS_VERIFY_DISABLE_TIME_CHECKS))
{
status |= check_time (trusted_cas[j], now);
if (status != 0)
{
if (func) func(certificate_list[i], trusted_cas[j], NULL, status);
return status;
}
}
if (func) func(certificate_list[i], trusted_cas[j], NULL, status);
clist_size = i;
break;
}
}
/* clist_size may have been changed which gets out of loop */
}
if (clist_size == 0)
{
/* The certificate is already present in the trusted certificate list.
* Nothing to verify. */
return status;
}
/* Verify the last certificate in the certificate path
* against the trusted CA certificate list.
*
* If no CAs are present returns CERT_INVALID. Thus works
* in self signed etc certificates.
*/
output = 0;
ret = _gnutls_verify_certificate2 (certificate_list[clist_size - 1],
trusted_cas, tcas_size, flags, &output,
&issuer, now, func);
if (ret == 0)
{
/* if the last certificate in the certificate
* list is invalid, then the certificate is not
* trusted.
*/
gnutls_assert ();
status |= output;
status |= GNUTLS_CERT_INVALID;
return status;
}
/* Verify the certificate path (chain)
*/
for (i = clist_size - 1; i > 0; i--)
{
output = 0;
if (i - 1 < 0)
break;
/* note that here we disable this V1 CA flag. So that no version 1
* certificates can exist in a supplied chain.
*/
if (!(flags & GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT))
flags &= ~(GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
if ((ret =
_gnutls_verify_certificate2 (certificate_list[i - 1],
&certificate_list[i], 1, flags,
&output, NULL, now, func)) == 0)
{
status |= output;
status |= GNUTLS_CERT_INVALID;
return status;
}
}
return 0;
}
|
↓
|
_gnutls_server_select_cert
|
18
|
47
|
124
|
auth/cert.c
|
int
_gnutls_server_select_cert (gnutls_session_t session,
gnutls_pk_algorithm_t * pk_algos,
size_t pk_algos_size)
{
unsigned i, j;
int idx, ret;
gnutls_certificate_credentials_t cred;
char server_name[MAX_CN];
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* If the callback which retrieves certificate has been set,
* use it and leave.
*/
if (cred->server_get_cert_callback != NULL || cred->server_get_cert_callback
|| cred->get_cert_callback2)
{
ret = call_get_cert_callback (session, NULL, 0, NULL, 0);
if (ret < 0)
return gnutls_assert_val (ret);
return ret;
}
/* Otherwise... */
get_server_name(session, server_name, sizeof(server_name));
idx = -1; /* default is use no certificate */
/* find certificates that match the requested server_name
*/
if (server_name[0] != 0)
{
for (i = 0; i < cred->ncerts; i++)
{
if (cred->certs[i].names != NULL && _gnutls_str_array_match(cred->certs[i].names, server_name) != 0)
{
/* if requested algorithms are also compatible select it */
gnutls_pk_algorithm pk =
gnutls_pubkey_get_pk_algorithm (cred->certs[i].cert_list[0].pubkey,
NULL);
_gnutls_handshake_log("HSK[%p]: Requested server name: '%s', ctype: %s (%d)", session, server_name,
gnutls_certificate_type_get_name (session->security_parameters.cert_type),
session->security_parameters.cert_type);
if (session->security_parameters.cert_type == cred->certs[i].cert_list[0].type)
{
for (j = 0; j < pk_algos_size; j++)
if (pk_algos[j] == pk)
{
idx = i;
goto finished;
}
}
}
}
}
for (j = 0; j < pk_algos_size; j++)
{
_gnutls_handshake_log
("HSK[%p]: Requested PK algorithm: %s (%d) -- ctype: %s (%d)\n",
session, gnutls_pk_get_name (pk_algos[j]), pk_algos[j],
gnutls_certificate_type_get_name (session->security_parameters.
cert_type),
session->security_parameters.cert_type);
for (i = 0; i < cred->ncerts; i++)
{
gnutls_pk_algorithm pk =
gnutls_pubkey_get_pk_algorithm (cred->certs[i].cert_list[0].pubkey,
NULL);
/* find one compatible certificate
*/
_gnutls_handshake_log
("HSK[%p]: certificate[%d] PK algorithm: %s (%d) - ctype: %s (%d)\n",
session, i, gnutls_pk_get_name (pk), pk,
gnutls_certificate_type_get_name (cred->certs[i].cert_list[0].type),
cred->certs[i].cert_list[0].type);
if (pk_algos[j] == pk)
{
/* if cert type matches
*/
/* *INDENT-OFF* */
if (session->security_parameters.cert_type == cred->certs[i].cert_list[0].type)
{
idx = i;
goto finished;
}
/* *INDENT-ON* */
}
}
}
/* store the certificate pointer for future use, in the handshake.
* (This will allow not calling this callback again.)
*/
finished:
if (idx >= 0)
{
_gnutls_selected_certs_set (session,
&cred->certs[idx].cert_list[0],
cred->certs[idx].cert_list_length,
cred->pkey[idx], 0);
}
else
{
gnutls_assert ();
/* Certificate does not support REQUESTED_ALGO. */
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
return 0;
}
|
↓
|
_gnutls_remove_unwanted_ciphersuites
|
18
|
42
|
127
|
gnutls_handshake.c
|
static int
_gnutls_remove_unwanted_ciphersuites (gnutls_session_t session,
uint8_t * cipher_suites,
int cipher_suites_size,
gnutls_pk_algorithm_t *pk_algos,
size_t pk_algos_size)
{
int ret = 0;
int i, new_suites_size;
gnutls_certificate_credentials_t cert_cred;
gnutls_kx_algorithm_t kx;
int server = session->security_parameters.entity == GNUTLS_SERVER ? 1 : 0;
gnutls_kx_algorithm_t alg[MAX_ALGOS];
int alg_size = MAX_ALGOS;
/* if we should use a specific certificate,
* we should remove all algorithms that are not supported
* by that certificate and are on the same authentication
* method (CERTIFICATE).
*/
cert_cred =
(gnutls_certificate_credentials_t) _gnutls_get_cred (session->key,
GNUTLS_CRD_CERTIFICATE,
NULL);
/* If there are certificate credentials, find an appropriate certificate
* or disable them;
*/
if (session->security_parameters.entity == GNUTLS_SERVER
&& cert_cred != NULL && pk_algos_size > 0)
{
ret = _gnutls_server_select_cert (session, pk_algos, pk_algos_size);
if (ret < 0)
{
gnutls_assert ();
_gnutls_debug_log ("Could not find an appropriate certificate: %s\n",
gnutls_strerror (ret));
}
}
/* get all the key exchange algorithms that are
* supported by the X509 certificate parameters.
*/
if ((ret =
_gnutls_selected_cert_supported_kx (session, alg, &alg_size)) < 0)
{
gnutls_assert ();
return ret;
}
new_suites_size = 0;
/* now removes ciphersuites based on the KX algorithm
*/
for (i = 0; i < cipher_suites_size; i+=2)
{
int delete = 0;
/* finds the key exchange algorithm in
* the ciphersuite
*/
kx = _gnutls_cipher_suite_get_kx_algo (&cipher_suites[i]);
/* if it is defined but had no credentials
*/
if (_gnutls_get_kx_cred (session, kx, NULL) == NULL)
{
delete = 1;
}
else
{
delete = 0;
if (server)
delete = check_server_params (session, kx, alg, alg_size);
}
/* If we have not agreed to a common curve with the peer don't bother
* negotiating ECDH.
*/
if (server != 0 && _gnutls_kx_is_ecc(kx))
{
if (_gnutls_session_ecc_curve_get(session) == GNUTLS_ECC_CURVE_INVALID)
{
delete = 1;
}
}
/* These two SRP kx's are marked to require a CRD_CERTIFICATE,
(see cred_mappings in gnutls_algorithms.c), but it also
requires a SRP credential. Don't use SRP kx unless we have a
SRP credential too. */
if (kx == GNUTLS_KX_SRP_RSA || kx == GNUTLS_KX_SRP_DSS)
{
if (!_gnutls_get_cred (session->key, GNUTLS_CRD_SRP, NULL))
{
delete = 1;
}
}
if (delete == 0)
{
_gnutls_handshake_log ("HSK[%p]: Keeping ciphersuite: %s\n",
session,
_gnutls_cipher_suite_get_name (&cipher_suites[i]));
if (i != new_suites_size)
memmove( &cipher_suites[new_suites_size], &cipher_suites[i], 2);
new_suites_size+=2;
}
else
{
_gnutls_handshake_log ("HSK[%p]: Removing ciphersuite: %s\n",
session,
_gnutls_cipher_suite_get_name (&cipher_suites[i]));
}
}
ret = new_suites_size;
return ret;
}
|
↓
|
keydb_find_byusage
|
18
|
22
|
42
|
opencdk/keydb.c
|
static cdk_kbnode_t
keydb_find_byusage (cdk_kbnode_t root, int req_usage, int is_pk)
{
cdk_kbnode_t node, key;
int req_type;
long timestamp;
req_type = is_pk ? CDK_PKT_PUBLIC_KEY : CDK_PKT_SECRET_KEY;
if (!req_usage)
return kbnode_find_valid (root, req_type);
node = cdk_kbnode_find (root, req_type);
if (node && !keydb_check_key (node->pkt))
return NULL;
key = NULL;
timestamp = 0;
/* We iteratre over the all nodes and search for keys or
subkeys which match the usage and which are not invalid.
A timestamp is used to figure out the newest valid key. */
for (node = root; node; node = node->next)
{
if (is_pk && (node->pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
node->pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY)
&& keydb_check_key (node->pkt)
&& (node->pkt->pkt.public_key->pubkey_usage & req_usage))
{
if (node->pkt->pkt.public_key->timestamp > timestamp)
key = node;
}
if (!is_pk && (node->pkt->pkttype == CDK_PKT_SECRET_KEY ||
node->pkt->pkttype == CDK_PKT_SECRET_SUBKEY)
&& keydb_check_key (node->pkt)
&& (node->pkt->pkt.secret_key->pk->pubkey_usage & req_usage))
{
if (node->pkt->pkt.secret_key->pk->timestamp > timestamp)
key = node;
}
}
return key;
}
|
↓
|
wrap_nettle_pk_generate_params
|
17
|
116
|
189
|
nettle/pk.c
|
static int
wrap_nettle_pk_generate_params (gnutls_pk_algorithm_t algo,
unsigned int level /*bits */ ,
gnutls_pk_params_st * params)
{
int ret, i;
int q_bits;
memset(params, 0, sizeof(*params));
switch (algo)
{
case GNUTLS_PK_DSA:
{
struct dsa_public_key pub;
struct dsa_private_key priv;
dsa_public_key_init (&pub);
dsa_private_key_init (&priv);
/* the best would be to use _gnutls_pk_bits_to_subgroup_bits()
* but we do NIST DSA here */
if (level <= 1024)
q_bits = 160;
else
q_bits = 256;
ret =
dsa_generate_keypair (&pub, &priv, NULL,
rnd_func, NULL, NULL, level, q_bits);
if (ret != 1)
{
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto dsa_fail;
}
params->params_nr = 0;
for (i = 0; i < DSA_PRIVATE_PARAMS; i++)
{
params->params[i] = _gnutls_mpi_alloc_like (&pub.p);
if (params->params[i] == NULL)
{
ret = GNUTLS_E_MEMORY_ERROR;
goto dsa_fail;
}
params->params_nr++;
}
ret = 0;
_gnutls_mpi_set (params->params[0], pub.p);
_gnutls_mpi_set (params->params[1], pub.q);
_gnutls_mpi_set (params->params[2], pub.g);
_gnutls_mpi_set (params->params[3], pub.y);
_gnutls_mpi_set (params->params[4], priv.x);
dsa_fail:
dsa_private_key_clear (&priv);
dsa_public_key_clear (&pub);
if (ret < 0)
goto fail;
break;
}
case GNUTLS_PK_RSA:
{
struct rsa_public_key pub;
struct rsa_private_key priv;
rsa_public_key_init (&pub);
rsa_private_key_init (&priv);
_gnutls_mpi_set_ui (&pub.e, 65537);
ret =
rsa_generate_keypair (&pub, &priv, NULL,
rnd_func, NULL, NULL, level, 0);
if (ret != 1)
{
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto rsa_fail;
}
params->params_nr = 0;
for (i = 0; i < RSA_PRIVATE_PARAMS; i++)
{
params->params[i] = _gnutls_mpi_alloc_like (&pub.n);
if (params->params[i] == NULL)
{
ret = GNUTLS_E_MEMORY_ERROR;
goto rsa_fail;
}
params->params_nr++;
}
ret = 0;
_gnutls_mpi_set (params->params[0], pub.n);
_gnutls_mpi_set (params->params[1], pub.e);
_gnutls_mpi_set (params->params[2], priv.d);
_gnutls_mpi_set (params->params[3], priv.p);
_gnutls_mpi_set (params->params[4], priv.q);
_gnutls_mpi_set (params->params[5], priv.c);
_gnutls_mpi_set (params->params[6], priv.a);
_gnutls_mpi_set (params->params[7], priv.b);
rsa_fail:
rsa_private_key_clear (&priv);
rsa_public_key_clear (&pub);
if (ret < 0)
goto fail;
break;
}
case GNUTLS_PK_EC:
{
ecc_key key;
ecc_set_type tls_ecc_set;
const gnutls_ecc_curve_entry_st *st;
st = _gnutls_ecc_curve_get_params(level);
if (st == NULL)
return gnutls_assert_val(GNUTLS_E_ECC_UNSUPPORTED_CURVE);
tls_ecc_set.size = st->size;
tls_ecc_set.prime = st->prime;
tls_ecc_set.order = st->order;
tls_ecc_set.Gx = st->Gx;
tls_ecc_set.Gy = st->Gy;
tls_ecc_set.A = st->A;
tls_ecc_set.B = st->B;
ret = ecc_make_key(NULL, rnd_func, &key, &tls_ecc_set);
if (ret != 0)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
params->params_nr = 0;
for (i = 0; i < ECC_PRIVATE_PARAMS; i++)
{
params->params[i] = _gnutls_mpi_alloc_like(&key.prime);
if (params->params[i] == NULL)
{
ret = GNUTLS_E_MEMORY_ERROR;
goto ecc_fail;
}
params->params_nr++;
}
params->flags = level;
mpz_set(TOMPZ(params->params[ECC_PRIME]), key.prime);
mpz_set(TOMPZ(params->params[ECC_ORDER]), key.order);
mpz_set(TOMPZ(params->params[ECC_A]), key.A);
mpz_set(TOMPZ(params->params[ECC_B]), key.B);
mpz_set(TOMPZ(params->params[ECC_GX]), key.Gx);
mpz_set(TOMPZ(params->params[ECC_GY]), key.Gy);
mpz_set(TOMPZ(params->params[ECC_X]), key.pubkey.x);
mpz_set(TOMPZ(params->params[ECC_Y]), key.pubkey.y);
mpz_set(TOMPZ(params->params[ECC_K]), key.k);
ecc_fail:
ecc_free(&key);
if (ret < 0)
goto fail;
break;
}
default:
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
return 0;
fail:
for (i = 0; i < params->params_nr; i++)
{
_gnutls_mpi_release (¶ms->params[i]);
}
params->params_nr = 0;
return ret;
}
|
↓
|
gnutls_dh_params_export_pkcs3
|
17
|
84
|
163
|
gnutls_dh_primes.c
|
int
gnutls_dh_params_export_pkcs3 (gnutls_dh_params_t params,
gnutls_x509_crt_fmt_t format,
unsigned char *params_data,
size_t * params_data_size)
{
ASN1_TYPE c2;
int result, _params_data_size;
size_t g_size, p_size;
opaque *p_data, *g_data;
opaque *all_data;
_gnutls_mpi_print_lz (params->params[1], NULL, &g_size);
_gnutls_mpi_print_lz (params->params[0], NULL, &p_size);
all_data = gnutls_malloc (g_size + p_size);
if (all_data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
p_data = &all_data[0];
_gnutls_mpi_print_lz (params->params[0], p_data, &p_size);
g_data = &all_data[p_size];
_gnutls_mpi_print_lz (params->params[1], g_data, &g_size);
/* Ok. Now we have the data. Create the asn1 structures
*/
if ((result = asn1_create_element
(_gnutls_get_gnutls_asn (), "GNUTLS.DHParameter", &c2))
!= ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (all_data);
return _gnutls_asn2err (result);
}
/* Write PRIME
*/
if ((result = asn1_write_value (c2, "prime",
p_data, p_size)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (all_data);
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
if (params->q_bits > 0)
result = _gnutls_x509_write_uint32 (c2, "privateValueLength", params->q_bits);
else
result = asn1_write_value (c2, "privateValueLength", NULL, 0);
if (result < 0)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
/* Write the GENERATOR
*/
if ((result = asn1_write_value (c2, "base",
g_data, g_size)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (all_data);
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
gnutls_free (all_data);
if (format == GNUTLS_X509_FMT_DER)
{
if (params_data == NULL)
*params_data_size = 0;
_params_data_size = *params_data_size;
result =
asn1_der_coding (c2, "", params_data, &_params_data_size, NULL);
*params_data_size = _params_data_size;
asn1_delete_structure (&c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
if (result == ASN1_MEM_ERROR)
return GNUTLS_E_SHORT_MEMORY_BUFFER;
return _gnutls_asn2err (result);
}
}
else
{ /* PEM */
opaque *tmp;
opaque *out;
int len;
len = 0;
asn1_der_coding (c2, "", NULL, &len, NULL);
tmp = gnutls_malloc (len);
if (tmp == NULL)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return GNUTLS_E_MEMORY_ERROR;
}
if ((result =
asn1_der_coding (c2, "", tmp, &len, NULL)) != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (tmp);
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
asn1_delete_structure (&c2);
result = _gnutls_fbase64_encode ("DH PARAMETERS", tmp, len, &out);
gnutls_free (tmp);
if (result < 0)
{
gnutls_assert ();
return result;
}
if (result == 0)
{ /* oooops */
gnutls_assert ();
gnutls_free (out);
return GNUTLS_E_INTERNAL_ERROR;
}
if ((unsigned) result > *params_data_size)
{
gnutls_assert ();
gnutls_free (out);
*params_data_size = result;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
*params_data_size = result - 1;
if (params_data)
memcpy (params_data, out, result);
gnutls_free (out);
}
return 0;
}
|
↓
|
ecc_projective_dbl_point
|
17
|
62
|
109
|
nettle/ecc_projective_dbl_point_3.c
|
int
ecc_projective_dbl_point (ecc_point * P, ecc_point * R, mpz_t a /* a is -3 */,
mpz_t modulus)
{
mpz_t t1, t2;
int err;
if (P == NULL || R == NULL || modulus == NULL)
return -1;
if ((err = mp_init_multi(&t1, &t2, NULL)) != 0) {
return err;
}
if (P != R) {
mpz_set(R->x, P->x);
mpz_set(R->y, P->y);
mpz_set(R->z, P->z);
}
/* t1 = Z * Z */
mpz_mul(t1, R->z, R->z);
mpz_mod(t1, t1, modulus);
/* Z = Y * Z */
mpz_mul(R->z, R->y, R->z);
mpz_mod(R->z, R->z, modulus);
/* Z = 2Z */
mpz_add(R->z, R->z, R->z);
if (mpz_cmp(R->z, modulus) >= 0) {
mpz_sub(R->z, R->z, modulus);
}
/* T2 = X - T1 */
mpz_sub(t2, R->x, t1);
if (mpz_cmp_ui(t2, 0) < 0) {
mpz_add(t2, t2, modulus);
}
/* T1 = X + T1 */
mpz_add(t1, t1, R->x);
if (mpz_cmp(t1, modulus) >= 0) {
mpz_sub(t1, t1, modulus);
}
/* T2 = T1 * T2 */
mpz_mul(t2, t1, t2);
mpz_mod(t2, t2, modulus);
/* T1 = 2T2 */
mpz_add(t1, t2, t2);
if (mpz_cmp(t1, modulus) >= 0) {
mpz_sub(t1, t1, modulus);
}
/* T1 = T1 + T2 */
mpz_add(t1, t1, t2);
if (mpz_cmp(t1, modulus) >= 0) {
mpz_sub(t1, t1, modulus);
}
/* Y = 2Y */
mpz_add(R->y, R->y, R->y);
if (mpz_cmp(R->y, modulus) >= 0) {
mpz_sub(R->y, R->y, modulus);
}
/* Y = Y * Y */
mpz_mul(R->y, R->y, R->y);
mpz_mod(R->y, R->y, modulus);
/* T2 = Y * Y */
mpz_mul(t2, R->y, R->y);
mpz_mod(t2, t2, modulus);
/* T2 = T2/2 */
if (mpz_odd_p(t2)) {
mpz_add(t2, t2, modulus);
}
mpz_divexact_ui(t2, t2, 2);
/* Y = Y * X */
mpz_mul(R->y, R->y, R->x);
mpz_mod(R->y, R->y, modulus);
/* X = T1 * T1 */
mpz_mul(R->x, t1, t1);
mpz_mod(R->x, R->x, modulus);
/* X = X - Y */
mpz_sub(R->x, R->x, R->y);
if (mpz_cmp_ui(R->x, 0) < 0) {
mpz_add(R->x, R->x, modulus);
}
/* X = X - Y */
mpz_sub(R->x, R->x, R->y);
if (mpz_cmp_ui(R->x, 0) < 0) {
mpz_add(R->x, R->x, modulus);
}
/* Y = Y - X */
mpz_sub(R->y, R->y, R->x);
if (mpz_cmp_ui(R->y, 0) < 0) {
mpz_add(R->y, R->y, modulus);
}
/* Y = Y * T1 */
mpz_mul(R->y, R->y, t1);
mpz_mod(R->y, R->y, modulus);
/* Y = Y - T2 */
mpz_sub(R->y, R->y, t2);
if (mpz_cmp_ui(R->y, 0) < 0) {
mpz_add( R->y, R->y, modulus);
}
err = 0;
mp_clear_multi(&t1, &t2, NULL);
return err;
}
|
↓
|
print_key_purpose
|
17
|
47
|
75
|
x509/output.c
|
static void
print_key_purpose (gnutls_buffer_st * str, const char *prefix, int type,
cert_type_t cert)
{
int indx;
char *buffer = NULL;
size_t size;
int err;
for (indx = 0;; indx++)
{
size = 0;
if (type == TYPE_CRT)
err = gnutls_x509_crt_get_key_purpose_oid (cert.crt, indx, buffer,
&size, NULL);
else if (type == TYPE_CRQ)
err = gnutls_x509_crq_get_key_purpose_oid (cert.crq, indx, buffer,
&size, NULL);
else
return;
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
return;
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
addf (str, "error: get_key_purpose_oid: %s\n",
gnutls_strerror (err));
return;
}
buffer = gnutls_malloc (size);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
return;
}
if (type == TYPE_CRT)
err = gnutls_x509_crt_get_key_purpose_oid (cert.crt, indx, buffer,
&size, NULL);
else
err = gnutls_x509_crq_get_key_purpose_oid (cert.crq, indx, buffer,
&size, NULL);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_key_purpose_oid2: %s\n",
gnutls_strerror (err));
return;
}
if (strcmp (buffer, GNUTLS_KP_TLS_WWW_SERVER) == 0)
addf (str, _("%s\t\t\tTLS WWW Server.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_TLS_WWW_CLIENT) == 0)
addf (str, _("%s\t\t\tTLS WWW Client.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_CODE_SIGNING) == 0)
addf (str, _("%s\t\t\tCode signing.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_EMAIL_PROTECTION) == 0)
addf (str, _("%s\t\t\tEmail protection.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_TIME_STAMPING) == 0)
addf (str, _("%s\t\t\tTime stamping.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_OCSP_SIGNING) == 0)
addf (str, _("%s\t\t\tOCSP signing.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_IPSEC_IKE) == 0)
addf (str, _("%s\t\t\tIpsec IKE.\n"), prefix);
else if (strcmp (buffer, GNUTLS_KP_ANY) == 0)
addf (str, _("%s\t\t\tAny purpose.\n"), prefix);
else
addf (str, "%s\t\t\t%s\n", prefix, buffer);
gnutls_free (buffer);
}
}
|
↓
|
ecc_verify_hash
|
17
|
44
|
102
|
nettle/ecc_verify_hash.c
|
int
ecc_verify_hash (struct dsa_signature *signature,
const unsigned char *hash, unsigned long hashlen,
int *stat, ecc_key * key)
{
ecc_point *mG, *mQ;
mpz_t v, w, u1, u2, e;
int err;
if (signature == NULL || hash == NULL || stat == NULL || key == NULL)
return -1;
/* default to invalid signature */
*stat = 0;
/* allocate ints */
if ((err = mp_init_multi (&v, &w, &u1, &u2, &e, NULL)) != 0)
{
return -1;
}
/* allocate points */
mG = ecc_new_point ();
mQ = ecc_new_point ();
if (mQ == NULL || mG == NULL)
{
err = -1;
goto error;
}
/* check for (0) */
if (mpz_cmp_ui (signature->r, 0) == 0 || mpz_cmp_ui (signature->s, 0) == 0
|| mpz_cmp (signature->r, key->order) >= 0
|| mpz_cmp (signature->s, key->order) >= 0)
{
err = -1;
goto error;
}
/* read hash */
nettle_mpz_set_str_256_u (e, hashlen, hash);
/* w = s^-1 mod n */
mpz_invert (w, signature->s, key->order);
/* u1 = ew */
mpz_mul (u1, e, w);
mpz_mod (u1, u1, key->order);
/* u2 = rw */
mpz_mul (u2, signature->r, w);
mpz_mod (u2, u2, key->order);
/* find mG and mQ */
mpz_set (mG->x, key->Gx);
mpz_set (mG->y, key->Gy);
mpz_set_ui (mG->z, 1);
mpz_set (mQ->x, key->pubkey.x);
mpz_set (mQ->y, key->pubkey.y);
mpz_set (mQ->z, key->pubkey.z);
/* compute u1*mG + u2*mQ = mG */
if ((err = ecc_mulmod (u1, mG, mG, key->A, key->prime, 0)) != 0)
{
goto error;
}
if ((err = ecc_mulmod (u2, mQ, mQ, key->A, key->prime, 0)) != 0)
{
goto error;
}
/* add them */
if ((err =
ecc_projective_add_point (mQ, mG, mG, key->A, key->prime)) != 0)
{
goto error;
}
/* reduce */
if ((err = ecc_map (mG, key->prime)) != 0)
{
goto error;
}
/* v = X_x1 mod n */
mpz_mod (v, mG->x, key->order);
/* does v == r */
if (mpz_cmp (v, signature->r) == 0)
{
*stat = 1;
}
/* clear up and return */
err = 0;
error:
ecc_del_point (mG);
ecc_del_point (mQ);
mp_clear_multi (&v, &w, &u1, &u2, &e, NULL);
return err;
}
|
↓
|
pkcs11_login
|
17
|
44
|
90
|
pkcs11.c
|
int
pkcs11_login (struct ck_function_list * module, ck_session_handle_t pks,
const struct token_info *tokinfo, struct p11_kit_uri *info, int so)
{
struct ck_session_info session_info;
int attempt = 0, ret;
ck_user_type_t user_type;
ck_rv_t rv;
user_type = (so == 0) ? CKU_USER : CKU_SO;
if (so == 0 && (tokinfo->tinfo.flags & CKF_LOGIN_REQUIRED) == 0)
{
gnutls_assert ();
_gnutls_debug_log ("pk11: No login required.\n");
return 0;
}
/* For a token with a "protected" (out-of-band) authentication
* path, calling login with a NULL username is all that is
* required. */
if (tokinfo->tinfo.flags & CKF_PROTECTED_AUTHENTICATION_PATH)
{
rv = (module)->C_Login (pks, (so == 0) ? CKU_USER : CKU_SO, NULL, 0);
if (rv == CKR_OK || rv == CKR_USER_ALREADY_LOGGED_IN)
{
return 0;
}
else
{
gnutls_assert ();
_gnutls_debug_log ("pk11: Protected login failed.\n");
ret = GNUTLS_E_PKCS11_ERROR;
goto cleanup;
}
}
do
{
struct p11_kit_pin *pin;
struct ck_token_info tinfo;
memcpy (&tinfo, &tokinfo->tinfo, sizeof(tinfo));
/* Check whether the session is already logged in, and if so, just skip */
rv = (module)->C_GetSessionInfo (pks, &session_info);
if (rv == CKR_OK && (session_info.state == CKS_RO_USER_FUNCTIONS ||
session_info.state == CKS_RW_USER_FUNCTIONS))
{
ret = 0;
goto cleanup;
}
/* If login has been attempted once already, check the token
* status again, the flags might change. */
if (attempt)
{
if (pkcs11_get_token_info
(tokinfo->prov->module, tokinfo->sid, &tinfo) != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("pk11: GetTokenInfo failed\n");
ret = GNUTLS_E_PKCS11_ERROR;
goto cleanup;
}
}
ret = retrieve_pin (info, &tinfo, attempt++, user_type, &pin);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
rv = (module)->C_Login (pks, user_type,
(unsigned char *)p11_kit_pin_get_value (pin, NULL),
p11_kit_pin_get_length (pin));
p11_kit_pin_unref (pin);
}
while (rv == CKR_PIN_INCORRECT);
_gnutls_debug_log ("pk11: Login result = %lu\n", rv);
ret = (rv == CKR_OK
|| rv == CKR_USER_ALREADY_LOGGED_IN) ? 0 : pkcs11_rv_to_err (rv);
cleanup:
return ret;
}
|
↓
|
parse_handshake_header
|
17
|
37
|
79
|
gnutls_buffers.c
|
static int
parse_handshake_header (gnutls_session_t session, mbuffer_st* bufel, gnutls_handshake_description_t htype,
handshake_buffer_st* hsk)
{
uint8_t *dataptr = NULL; /* for realloc */
size_t handshake_header_size = HANDSHAKE_HEADER_SIZE(session), data_size;
/* Note: SSL2_HEADERS == 1 */
if (_mbuffer_get_udata_size(bufel) < handshake_header_size)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
dataptr = _mbuffer_get_udata_ptr(bufel);
/* if reading a client hello of SSLv2 */
if (!IS_DTLS(session) && htype == GNUTLS_HANDSHAKE_CLIENT_HELLO &&
bufel->htype == GNUTLS_HANDSHAKE_CLIENT_HELLO_V2)
{
handshake_header_size = SSL2_HEADERS; /* we've already read one byte */
hsk->length = _mbuffer_get_udata_size(bufel) - handshake_header_size; /* we've read the first byte */
if (dataptr[0] != GNUTLS_HANDSHAKE_CLIENT_HELLO)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET);
hsk->htype = GNUTLS_HANDSHAKE_CLIENT_HELLO_V2;
hsk->sequence = 0;
hsk->start_offset = 0;
hsk->end_offset = hsk->length;
}
else /* TLS handshake headers */
{
hsk->htype = dataptr[0];
/* we do not use DECR_LEN because we know
* that the packet has enough data.
*/
hsk->length = _gnutls_read_uint24 (&dataptr[1]);
handshake_header_size = HANDSHAKE_HEADER_SIZE(session);
if (IS_DTLS(session))
{
hsk->sequence = _gnutls_read_uint16 (&dataptr[4]);
hsk->start_offset = _gnutls_read_uint24 (&dataptr[6]);
hsk->end_offset = hsk->start_offset + _gnutls_read_uint24 (&dataptr[9]);
}
else
{
hsk->sequence = 0;
hsk->start_offset = 0;
hsk->end_offset = hsk->length;
}
}
data_size = _mbuffer_get_udata_size(bufel) - handshake_header_size;
/* make the length offset */
if (hsk->end_offset > 0) hsk->end_offset--;
_gnutls_handshake_log ("HSK[%p]: %s was received. Length %d[%d], frag offset %d, frag length: %d, sequence: %d\n",
session, _gnutls_handshake2str (hsk->htype),
(int) hsk->length, (int)data_size, hsk->start_offset, hsk->end_offset-hsk->start_offset+1, (int)hsk->sequence);
hsk->header_size = handshake_header_size;
memcpy(hsk->header, _mbuffer_get_udata_ptr(bufel), handshake_header_size);
if (hsk->length > 0 &&
(hsk->end_offset-hsk->start_offset >= data_size))
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
if (hsk->length > 0 && (hsk->start_offset >= hsk->end_offset ||
hsk->end_offset-hsk->start_offset >= data_size ||
hsk->end_offset >= hsk->length))
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
else if (hsk->length == 0 && hsk->end_offset != 0 && hsk->start_offset != 0)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
return handshake_header_size;
}
|
↓
|
base64_decode
|
17
|
34
|
59
|
opencdk/armor.c
|
static int
base64_decode (byte * out, const char *in)
{
size_t len;
byte digit1, digit2, digit3, digit4;
if (!out || !in)
{
gnutls_assert ();
return -1;
}
len = 0;
do
{
digit1 = in[0];
if (digit1 > 127 || b64val (digit1) == BAD)
{
gnutls_assert ();
return -1;
}
digit2 = in[1];
if (digit2 > 127 || b64val (digit2) == BAD)
{
gnutls_assert ();
return -1;
}
digit3 = in[2];
if (digit3 > 127 || ((digit3 != '=') && (b64val (digit3) == BAD)))
{
gnutls_assert ();
return -1;
}
digit4 = in[3];
if (digit4 > 127 || ((digit4 != '=') && (b64val (digit4) == BAD)))
{
gnutls_assert ();
return -1;
}
in += 4;
/* digits are already sanity-checked */
*out++ = (b64val (digit1) << 2) | (b64val (digit2) >> 4);
len++;
if (digit3 != '=')
{
*out++ = ((b64val (digit2) << 4) & 0xf0) | (b64val (digit3) >> 2);
len++;
if (digit4 != '=')
{
*out++ = ((b64val (digit3) << 6) & 0xc0) | b64val (digit4);
len++;
}
}
}
while (*in && digit4 != '=');
return len;
}
|
↓
|
privkey_to_pubkey
|
16
|
39
|
74
|
gnutls_privkey.c
|
static int
privkey_to_pubkey (gnutls_pk_algorithm_t pk,
const gnutls_pk_params_st* priv,
gnutls_pk_params_st* pub)
{
int ret;
switch (pk)
{
case GNUTLS_PK_RSA:
pub->params[0] = _gnutls_mpi_copy (priv->params[0]);
pub->params[1] = _gnutls_mpi_copy (priv->params[1]);
pub->params_nr = RSA_PUBLIC_PARAMS;
if (pub->params[0] == NULL || pub->params[1] == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
break;
case GNUTLS_PK_DSA:
pub->params[0] = _gnutls_mpi_copy (priv->params[0]);
pub->params[1] = _gnutls_mpi_copy (priv->params[1]);
pub->params[2] = _gnutls_mpi_copy (priv->params[2]);
pub->params[3] = _gnutls_mpi_copy (priv->params[3]);
pub->params_nr = DSA_PUBLIC_PARAMS;
if (pub->params[0] == NULL || pub->params[1] == NULL ||
pub->params[2] == NULL || pub->params[3] == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
break;
case GNUTLS_PK_EC:
pub->params[0] = _gnutls_mpi_copy (priv->params[0]);
pub->params[1] = _gnutls_mpi_copy (priv->params[1]);
pub->params[2] = _gnutls_mpi_copy (priv->params[2]);
pub->params[3] = _gnutls_mpi_copy (priv->params[3]);
pub->params[4] = _gnutls_mpi_copy (priv->params[4]);
pub->params[5] = _gnutls_mpi_copy (priv->params[5]);
pub->params[6] = _gnutls_mpi_copy (priv->params[6]);
pub->params[7] = _gnutls_mpi_copy (priv->params[7]);
pub->params_nr = ECC_PUBLIC_PARAMS;
pub->flags = priv->flags;
if (pub->params[0] == NULL || pub->params[1] == NULL ||
pub->params[2] == NULL || pub->params[3] == NULL ||
pub->params[4] == NULL || pub->params[5] == NULL ||
pub->params[6] == NULL || pub->params[7] == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
break;
default:
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
return 0;
cleanup:
gnutls_pk_params_release(pub);
return ret;
}
|
↓
|
delete_obj_url
|
16
|
58
|
112
|
pkcs11_write.c
|
static int
delete_obj_url (struct ck_function_list *module,
ck_session_handle_t pks,
struct token_info *info,
struct ck_info *lib_info, void *input)
{
struct delete_data_st *find_data = input;
struct ck_attribute a[4];
struct ck_attribute *attr;
ck_object_class_t class;
ck_certificate_type_t type = -1;
ck_rv_t rv;
ck_object_handle_t obj;
unsigned long count, a_vals;
int found = 0, ret;
if (info == NULL)
{ /* we don't support multiple calls */
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
/* do not bother reading the token if basic fields do not match
*/
if (!p11_kit_uri_match_module_info (find_data->info, lib_info) ||
!p11_kit_uri_match_token_info (find_data->info, &info->tinfo))
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
/* Find objects with given class and type */
class = CKO_CERTIFICATE; /* default */
a_vals = 0;
attr = p11_kit_uri_get_attribute (find_data->info, CKA_CLASS);
if (attr != NULL)
{
if(attr->value && attr->value_len == sizeof (ck_object_class_t))
class = *((ck_object_class_t*)attr->value);
if (class == CKO_CERTIFICATE)
type = CKC_X_509;
}
a[a_vals].type = CKA_CLASS;
a[a_vals].value = &class;
a[a_vals].value_len = sizeof (class);
a_vals++;
attr = p11_kit_uri_get_attribute (find_data->info, CKA_ID);
if (attr != NULL)
{
memcpy (a + a_vals, attr, sizeof (struct ck_attribute));
a_vals++;
}
if (type != -1)
{
a[a_vals].type = CKA_CERTIFICATE_TYPE;
a[a_vals].value = &type;
a[a_vals].value_len = sizeof type;
a_vals++;
}
attr = p11_kit_uri_get_attribute (find_data->info, CKA_LABEL);
if (attr != NULL)
{
memcpy (a + a_vals, attr, sizeof (struct ck_attribute));
a_vals++;
}
rv = pkcs11_find_objects_init (module, pks, a, a_vals);
if (rv != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("pk11: FindObjectsInit failed.\n");
ret = pkcs11_rv_to_err (rv);
goto cleanup;
}
while (pkcs11_find_objects (module, pks, &obj, 1, &count) == CKR_OK && count == 1)
{
rv = pkcs11_destroy_object (module, pks, obj);
if (rv != CKR_OK)
{
_gnutls_debug_log
("pkcs11: Cannot destroy object: %s\n", pkcs11_strerror (rv));
}
else
{
find_data->deleted++;
}
found = 1;
}
if (found == 0)
{
gnutls_assert ();
ret = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
else
{
ret = 0;
}
cleanup:
pkcs11_find_objects_final (module, pks);
return ret;
}
|
↓
|
compressed_to_ciphertext
|
16
|
58
|
134
|
gnutls_cipher.c
|
static int
compressed_to_ciphertext (gnutls_session_t session,
opaque * cipher_data, int cipher_size,
gnutls_datum_t *compressed,
content_type_t type,
record_parameters_st * params)
{
uint8_t * tag_ptr = NULL;
uint8_t pad;
int length, length_to_encrypt, ret;
opaque preamble[MAX_PREAMBLE_SIZE];
int preamble_size;
int tag_size = _gnutls_auth_cipher_tag_len (¶ms->write.cipher_state);
int blocksize = gnutls_cipher_get_block_size (params->cipher_algorithm);
unsigned block_algo =
_gnutls_cipher_is_block (params->cipher_algorithm);
opaque *data_ptr;
int ver = gnutls_protocol_get_version (session);
int explicit_iv = _gnutls_version_has_explicit_iv (session->security_parameters.version);
int auth_cipher = _gnutls_auth_cipher_is_aead(¶ms->write.cipher_state);
int random_pad;
/* We don't use long padding if requested or if we are in DTLS.
*/
if (session->internals.priorities.no_padding == 0 && (!IS_DTLS(session)))
random_pad = 1;
else
random_pad = 0;
_gnutls_hard_log("ENC[%p]: cipher: %s, MAC: %s, Epoch: %u\n",
session, gnutls_cipher_get_name(params->cipher_algorithm), gnutls_mac_get_name(params->mac_algorithm),
(unsigned int)params->epoch);
preamble_size =
make_preamble (UINT64DATA
(params->write.sequence_number),
type, compressed->size, ver, preamble);
/* Calculate the encrypted length (padding etc.)
*/
length_to_encrypt = length =
calc_enc_length (session, compressed->size, tag_size, &pad,
random_pad, block_algo, auth_cipher, blocksize);
if (length < 0)
{
return gnutls_assert_val(length);
}
/* copy the encrypted data to cipher_data.
*/
if (cipher_size < length)
{
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
}
data_ptr = cipher_data;
if (explicit_iv)
{
if (block_algo == CIPHER_BLOCK)
{
/* copy the random IV.
*/
ret = _gnutls_rnd (GNUTLS_RND_NONCE, data_ptr, blocksize);
if (ret < 0)
return gnutls_assert_val(ret);
_gnutls_auth_cipher_setiv(¶ms->write.cipher_state, data_ptr, blocksize);
data_ptr += blocksize;
cipher_data += blocksize;
length_to_encrypt -= blocksize;
}
else if (auth_cipher)
{
uint8_t nonce[blocksize];
/* Values in AEAD are pretty fixed in TLS 1.2 for 128-bit block
*/
if (params->write.IV.data == NULL || params->write.IV.size != AEAD_IMPLICIT_DATA_SIZE)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
/* Instead of generating a new nonce on every packet, we use the
* write.sequence_number (It is a MAY on RFC 5288).
*/
memcpy(nonce, params->write.IV.data, params->write.IV.size);
memcpy(&nonce[AEAD_IMPLICIT_DATA_SIZE], UINT64DATA(params->write.sequence_number), 8);
_gnutls_auth_cipher_setiv(¶ms->write.cipher_state, nonce, AEAD_IMPLICIT_DATA_SIZE+AEAD_EXPLICIT_DATA_SIZE);
/* copy the explicit part */
memcpy(data_ptr, &nonce[AEAD_IMPLICIT_DATA_SIZE], AEAD_EXPLICIT_DATA_SIZE);
data_ptr += AEAD_EXPLICIT_DATA_SIZE;
cipher_data += AEAD_EXPLICIT_DATA_SIZE;
/* In AEAD ciphers we don't encrypt the tag
*/
length_to_encrypt -= AEAD_EXPLICIT_DATA_SIZE + tag_size;
}
}
else
{
/* AEAD ciphers have an explicit IV. Shouldn't be used otherwise.
*/
if (auth_cipher) return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
}
memcpy (data_ptr, compressed->data, compressed->size);
data_ptr += compressed->size;
if (tag_size > 0)
{
tag_ptr = data_ptr;
data_ptr += tag_size;
}
if (block_algo == CIPHER_BLOCK && pad > 0)
{
memset (data_ptr, pad - 1, pad);
}
/* add the authenticate data */
_gnutls_auth_cipher_add_auth(¶ms->write.cipher_state, preamble, preamble_size);
/* Actual encryption (inplace).
*/
ret =
_gnutls_auth_cipher_encrypt_tag (¶ms->write.cipher_state,
cipher_data, length_to_encrypt, tag_ptr, tag_size, compressed->size);
if (ret < 0)
return gnutls_assert_val(ret);
return length;
}
|
↓
|
_pkcs12_encode_safe_contents
|
16
|
51
|
122
|
x509/pkcs12.c
|
int
_pkcs12_encode_safe_contents (gnutls_pkcs12_bag_t bag, ASN1_TYPE * contents,
int *enc)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int result;
int i;
const char *oid;
if (bag->element[0].type == GNUTLS_BAG_ENCRYPTED && enc)
{
*enc = 1;
return 0; /* ENCRYPTED BAG, do nothing. */
}
else if (enc)
*enc = 0;
/* Step 1. Create the SEQUENCE.
*/
if ((result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.pkcs-12-SafeContents",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
for (i = 0; i < bag->bag_elements; i++)
{
oid = bag_to_oid (bag->element[i].type);
if (oid == NULL)
{
gnutls_assert ();
continue;
}
result = asn1_write_value (c2, "", "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Copy the bag type.
*/
result = asn1_write_value (c2, "?LAST.bagId", oid, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Set empty attributes
*/
result = write_attributes (bag, i, c2, "?LAST.bagAttributes");
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
/* Copy the Bag Value
*/
if (bag->element[i].type == GNUTLS_BAG_CERTIFICATE ||
bag->element[i].type == GNUTLS_BAG_SECRET ||
bag->element[i].type == GNUTLS_BAG_CRL)
{
gnutls_datum_t tmp;
/* in that case encode it to a CertBag or
* a CrlBag.
*/
result =
_pkcs12_encode_crt_bag (bag->element[i].type,
&bag->element[i].data, &tmp);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result = _gnutls_x509_write_value (c2, "?LAST.bagValue", &tmp, 0);
_gnutls_free_datum (&tmp);
}
else
{
result = _gnutls_x509_write_value (c2, "?LAST.bagValue",
&bag->element[i].data, 0);
}
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
}
/* Encode the data and copy them into the datum
*/
*contents = c2;
return 0;
cleanup:
if (c2)
asn1_delete_structure (&c2);
return result;
}
|
↓
|
_gnutls_io_read_buffered
|
16
|
41
|
111
|
gnutls_buffers.c
|
ssize_t
_gnutls_io_read_buffered (gnutls_session_t session, size_t total,
content_type_t recv_type)
{
ssize_t ret = 0;
size_t min;
mbuffer_st *bufel = NULL;
size_t recvdata, readsize;
if (total > MAX_RECV_SIZE(session) || total == 0)
{
gnutls_assert (); /* internal error */
return GNUTLS_E_INVALID_REQUEST;
}
/* calculate the actual size, ie. get the minimum of the
* buffered data and the requested data.
*/
min = MIN (session->internals.record_recv_buffer.byte_length, total);
if (min > 0)
{
/* if we have enough buffered data
* then just return them.
*/
if (min == total)
{
return min;
}
}
/* min is over zero. recvdata is the data we must
* receive in order to return the requested data.
*/
recvdata = total - min;
readsize = recvdata;
/* Check if the previously read data plus the new data to
* receive are longer than the maximum receive buffer size.
*/
if ((session->internals.record_recv_buffer.byte_length + recvdata) >
MAX_RECV_SIZE(session))
{
gnutls_assert (); /* internal error */
return GNUTLS_E_INVALID_REQUEST;
}
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* READ DATA - but leave RCVLOWAT bytes in the kernel buffer.
*/
if (readsize > 0)
{
ret =
_gnutls_read (session, &bufel, readsize,
session->internals.pull_func);
/* return immediately if we got an interrupt or eagain
* error.
*/
if (ret < 0 && gnutls_error_is_fatal (ret) == 0)
{
_mbuffer_xfree (&bufel);
return ret;
}
}
/* copy fresh data to our buffer.
*/
if (ret > 0)
{
_gnutls_read_log
("RB: Have %d bytes into buffer. Adding %d bytes.\n",
(int) session->internals.record_recv_buffer.byte_length, (int) ret);
_gnutls_read_log ("RB: Requested %d bytes\n", (int) total);
_mbuffer_enqueue (&session->internals.record_recv_buffer, bufel);
}
else
_mbuffer_xfree (&bufel);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (ret == 0)
{ /* EOF */
gnutls_assert ();
return 0;
}
if(IS_DTLS(session))
ret = MIN(total, session->internals.record_recv_buffer.byte_length);
else
ret = session->internals.record_recv_buffer.byte_length;
if ((ret > 0) && ((size_t) ret < total))
{
/* Short Read */
return gnutls_assert_val(GNUTLS_E_AGAIN);
}
else
{
return ret;
}
}
|
↓
|
_gnutls_ext_sr_verify
|
16
|
40
|
107
|
ext/safe_renegotiation.c
|
int
_gnutls_ext_sr_verify (gnutls_session_t session)
{
int ret;
sr_ext_st *priv = NULL;
extension_priv_data_t epriv;
if (session->internals.priorities.sr == SR_DISABLED)
{
gnutls_assert ();
return 0;
}
ret = _gnutls_ext_get_session_data (session,
GNUTLS_EXTENSION_SAFE_RENEGOTIATION,
&epriv);
if (ret >= 0)
priv = epriv.ptr;
/* Safe renegotiation */
if (priv && priv->safe_renegotiation_received)
{
if ((priv->ri_extension_data_len < priv->client_verify_data_len) ||
(memcmp (priv->ri_extension_data,
priv->client_verify_data, priv->client_verify_data_len)))
{
gnutls_assert ();
_gnutls_handshake_log ("HSK[%p]: Safe renegotiation failed [1]\n",
session);
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
if ((priv->ri_extension_data_len !=
priv->client_verify_data_len + priv->server_verify_data_len) ||
memcmp (priv->ri_extension_data + priv->client_verify_data_len,
priv->server_verify_data,
priv->server_verify_data_len) != 0)
{
gnutls_assert ();
_gnutls_handshake_log
("HSK[%p]: Safe renegotiation failed [2]\n", session);
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
}
else /* Make sure there are 0 extra bytes */
{
if (priv->ri_extension_data_len != priv->client_verify_data_len)
{
gnutls_assert ();
_gnutls_handshake_log
("HSK[%p]: Safe renegotiation failed [3]\n", session);
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
}
_gnutls_handshake_log ("HSK[%p]: Safe renegotiation succeeded\n",
session);
}
else /* safe renegotiation not received... */
{
if (priv && priv->connection_using_safe_renegotiation)
{
gnutls_assert ();
_gnutls_handshake_log
("HSK[%p]: Peer previously asked for safe renegotiation\n",
session);
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
/* Clients can't tell if it's an initial negotiation */
if (session->internals.initial_negotiation_completed)
{
if (session->internals.priorities.sr < SR_PARTIAL)
{
_gnutls_handshake_log
("HSK[%p]: Allowing unsafe (re)negotiation\n", session);
}
else
{
gnutls_assert ();
_gnutls_handshake_log
("HSK[%p]: Denying unsafe (re)negotiation\n", session);
return GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED;
}
}
else
{
if (session->internals.priorities.sr < SR_SAFE)
{
_gnutls_handshake_log
("HSK[%p]: Allowing unsafe initial negotiation\n", session);
}
else
{
gnutls_assert ();
_gnutls_handshake_log
("HSK[%p]: Denying unsafe initial negotiation\n", session);
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
}
}
return 0;
}
|
↓
|
cdk_kbnode_write_to_mem
|
16
|
35
|
61
|
opencdk/kbnode.c
|
cdk_error_t
cdk_kbnode_write_to_mem (cdk_kbnode_t node, byte * buf, size_t * r_nbytes)
{
cdk_kbnode_t n;
cdk_stream_t s;
cdk_error_t rc;
size_t len;
if (!node || !r_nbytes)
{
gnutls_assert ();
return CDK_Inv_Value;
}
rc = cdk_stream_tmp_new (&s);
if (rc)
{
gnutls_assert ();
return rc;
}
for (n = node; n; n = n->next)
{
/* Skip all packets which cannot occur in a key composition. */
if (n->pkt->pkttype != CDK_PKT_PUBLIC_KEY &&
n->pkt->pkttype != CDK_PKT_PUBLIC_SUBKEY &&
n->pkt->pkttype != CDK_PKT_SECRET_KEY &&
n->pkt->pkttype != CDK_PKT_SECRET_SUBKEY &&
n->pkt->pkttype != CDK_PKT_SIGNATURE &&
n->pkt->pkttype != CDK_PKT_USER_ID &&
n->pkt->pkttype != CDK_PKT_ATTRIBUTE)
continue;
rc = cdk_pkt_write (s, n->pkt);
if (rc)
{
cdk_stream_close (s);
gnutls_assert ();
return rc;
}
}
cdk_stream_seek (s, 0);
len = cdk_stream_get_length (s);
if (!buf)
{
*r_nbytes = len; /* Only return the length of the buffer */
cdk_stream_close (s);
return 0;
}
if (*r_nbytes < len)
{
*r_nbytes = len;
rc = CDK_Too_Short;
}
if (!rc)
*r_nbytes = cdk_stream_read (s, buf, len);
else
gnutls_assert ();
cdk_stream_close (s);
return rc;
}
|
↓
|
write_public_key
|
16
|
35
|
46
|
opencdk/write-packet.c
|
static cdk_error_t
write_public_key (cdk_stream_t out, cdk_pkt_pubkey_t pk,
int is_subkey, int old_ctb)
{
int pkttype, ndays = 0;
size_t npkey = 0, size = 6;
cdk_error_t rc;
assert (out);
assert (pk);
if (pk->version < 2 || pk->version > 4)
return CDK_Inv_Packet;
if (DEBUG_PKT)
_gnutls_write_log ("write_public_key: subkey=%d\n", is_subkey);
pkttype = is_subkey ? CDK_PKT_PUBLIC_SUBKEY : CDK_PKT_PUBLIC_KEY;
npkey = cdk_pk_get_npkey (pk->pubkey_algo);
if (!npkey)
return CDK_Inv_Algo;
if (pk->version < 4)
size += 2; /* expire date */
if (is_subkey)
old_ctb = 0;
size += calc_mpisize (pk->mpi, npkey);
if (old_ctb)
rc = pkt_write_head2 (out, size, pkttype);
else
rc = pkt_write_head (out, old_ctb, size, pkttype);
if (!rc)
rc = stream_putc (out, pk->version);
if (!rc)
rc = write_32 (out, pk->timestamp);
if (!rc && pk->version < 4)
{
if (pk->expiredate)
ndays = (u16) ((pk->expiredate - pk->timestamp) / 86400L);
rc = write_16 (out, ndays);
}
if (!rc)
rc = stream_putc (out, _cdk_pub_algo_to_pgp (pk->pubkey_algo));
if (!rc)
rc = write_mpibuf (out, pk->mpi, npkey);
return rc;
}
|
↓
|
cdk_stream_read
|
16
|
31
|
54
|
opencdk/stream.c
|
int
cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen)
{
int nread;
int rc;
if (!s)
{
gnutls_assert ();
return EOF;
}
if (s->cbs_hd)
{
if (s->cbs.read)
return s->cbs.read (s->cbs_hd, buf, buflen);
return 0;
}
if (s->flags.write && !s->flags.temp)
{
s->error = CDK_Inv_Mode;
gnutls_assert ();
return EOF; /* This is a write stream */
}
if (!s->flags.no_filter && !s->cache.on && !s->flags.filtrated)
{
rc = stream_filter_read (s);
if (rc)
{
s->error = rc;
if (s->fp && feof (s->fp))
s->flags.eof = 1;
gnutls_assert ();
return EOF;
}
s->flags.filtrated = 1;
}
if (!buf && !buflen)
return 0;
nread = fread (buf, 1, buflen, s->fp);
if (!nread)
nread = EOF;
if (feof (s->fp))
{
s->error = 0;
s->flags.eof = 1;
}
return nread;
}
|
↓
|
cdk_keydb_search_start
|
15
|
77
|
136
|
opencdk/keydb.c
|
cdk_error_t
cdk_keydb_search_start (cdk_keydb_search_t * st, cdk_keydb_hd_t db, int type,
void *desc)
{
u32 *keyid;
char *p, tmp[3];
int i;
cdk_error_t rc;
if (!db)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (type != CDK_DBSEARCH_NEXT && !desc)
{
gnutls_assert ();
return CDK_Inv_Mode;
}
*st = cdk_calloc (1, sizeof (cdk_keydb_search_s));
if (!(*st))
{
gnutls_assert ();
return CDK_Out_Of_Core;
}
rc = idx_init (db, *st);
if (rc != CDK_Success)
{
free (*st);
gnutls_assert ();
return rc;
}
(*st)->type = type;
switch (type)
{
case CDK_DBSEARCH_EXACT:
case CDK_DBSEARCH_SUBSTR:
cdk_free ((*st)->u.pattern);
(*st)->u.pattern = cdk_strdup (desc);
if (!(*st)->u.pattern)
{
cdk_free (*st);
gnutls_assert ();
return CDK_Out_Of_Core;
}
break;
case CDK_DBSEARCH_SHORT_KEYID:
keyid = desc;
(*st)->u.keyid[1] = keyid[0];
break;
case CDK_DBSEARCH_KEYID:
keyid = desc;
(*st)->u.keyid[0] = keyid[0];
(*st)->u.keyid[1] = keyid[1];
break;
case CDK_DBSEARCH_FPR:
memcpy ((*st)->u.fpr, desc, KEY_FPR_LEN);
break;
case CDK_DBSEARCH_NEXT:
break;
case CDK_DBSEARCH_AUTO:
/* Override the type with the actual db search type. */
(*st)->type = classify_data (desc, strlen (desc));
switch ((*st)->type)
{
case CDK_DBSEARCH_SUBSTR:
case CDK_DBSEARCH_EXACT:
cdk_free ((*st)->u.pattern);
p = (*st)->u.pattern = cdk_strdup (desc);
if (!p)
{
cdk_free (*st);
gnutls_assert ();
return CDK_Out_Of_Core;
}
break;
case CDK_DBSEARCH_SHORT_KEYID:
case CDK_DBSEARCH_KEYID:
p = desc;
if (!strncmp (p, "0x", 2))
p += 2;
if (strlen (p) == 8)
{
(*st)->u.keyid[0] = 0;
(*st)->u.keyid[1] = strtoul (p, NULL, 16);
}
else if (strlen (p) == 16)
{
(*st)->u.keyid[0] = strtoul (p, NULL, 16);
(*st)->u.keyid[1] = strtoul (p + 8, NULL, 16);
}
else
{ /* Invalid key ID object. */
cdk_free (*st);
gnutls_assert ();
return CDK_Inv_Mode;
}
break;
case CDK_DBSEARCH_FPR:
p = desc;
if (strlen (p) != 2 * KEY_FPR_LEN)
{
cdk_free (*st);
gnutls_assert ();
return CDK_Inv_Mode;
}
for (i = 0; i < KEY_FPR_LEN; i++)
{
tmp[0] = p[2 * i];
tmp[1] = p[2 * i + 1];
tmp[2] = 0x00;
(*st)->u.fpr[i] = strtoul (tmp, NULL, 16);
}
break;
}
break;
default:
cdk_free (*st);
_cdk_log_debug ("cdk_keydb_search_start: invalid mode = %d\n", type);
gnutls_assert ();
return CDK_Inv_Mode;
}
return 0;
}
|
↓
|
gnutls_pkcs11_copy_x509_privkey
|
15
|
194
|
306
|
pkcs11_write.c
|
int
gnutls_pkcs11_copy_x509_privkey (const char *token_url,
gnutls_x509_privkey_t key,
const char *label,
unsigned int key_usage, unsigned int flags)
{
int ret;
struct ck_function_list *module;
ck_session_handle_t pks = 0;
struct p11_kit_uri *info = NULL;
ck_rv_t rv;
size_t id_size;
opaque id[20];
struct ck_attribute a[16];
ck_object_class_t class = CKO_PRIVATE_KEY;
ck_object_handle_t obj;
ck_key_type_t type;
int a_val;
gnutls_pk_algorithm_t pk;
gnutls_datum_t p, q, g, y, x;
gnutls_datum_t m, e, d, u, exp1, exp2;
memset(&p, 0, sizeof(p));
memset(&q, 0, sizeof(q));
memset(&g, 0, sizeof(g));
memset(&y, 0, sizeof(y));
memset(&x, 0, sizeof(x));
memset(&m, 0, sizeof(m));
memset(&e, 0, sizeof(e));
memset(&d, 0, sizeof(d));
memset(&u, 0, sizeof(u));
memset(&exp1, 0, sizeof(exp1));
memset(&exp2, 0, sizeof(exp2));
ret = pkcs11_url_to_info (token_url, &info);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
id_size = sizeof (id);
ret = gnutls_x509_privkey_get_key_id (key, 0, id, &id_size);
if (ret < 0)
{
p11_kit_uri_free (info);
gnutls_assert ();
return ret;
}
ret =
pkcs11_open_session (&module, &pks, info,
SESSION_WRITE | pkcs11_obj_flags_to_int (flags));
p11_kit_uri_free (info);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* FIXME: copy key usage flags */
a_val = 0;
a[a_val].type = CKA_CLASS;
a[a_val].value = &class;
a[a_val].value_len = sizeof (class);
a_val++;
a[a_val].type = CKA_ID;
a[a_val].value = id;
a[a_val].value_len = id_size;
a_val++;
a[a_val].type = CKA_KEY_TYPE;
a[a_val].value = &type;
a[a_val].value_len = sizeof (type);
a_val++;
a[a_val].type = CKA_TOKEN;
a[a_val].value = (void*)&tval;
a[a_val].value_len = sizeof (tval);
a_val++;
/* a private key is set always as private unless
* requested otherwise
*/
if (flags & GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE)
{
a[a_val].type = CKA_PRIVATE;
a[a_val].value = (void*)&fval;
a[a_val].value_len = sizeof(fval);
a_val++;
}
else
{
a[a_val].type = CKA_PRIVATE;
a[a_val].value = (void*)&tval;
a[a_val].value_len = sizeof (tval);
a_val++;
}
if (label)
{
a[a_val].type = CKA_LABEL;
a[a_val].value = (void *) label;
a[a_val].value_len = strlen (label);
a_val++;
}
if (flags & GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE)
{
a[a_val].type = CKA_SENSITIVE;
a[a_val].value = (void*)&tval;
a[a_val].value_len = sizeof (tval);
a_val++;
}
else
{
a[a_val].type = CKA_SENSITIVE;
a[a_val].value = (void*)&fval;
a[a_val].value_len = sizeof (fval);
a_val++;
}
pk = gnutls_x509_privkey_get_pk_algorithm (key);
switch (pk)
{
case GNUTLS_PK_RSA:
{
ret =
gnutls_x509_privkey_export_rsa_raw2 (key, &m,
&e, &d, &p,
&q, &u, &exp1, &exp2);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
type = CKK_RSA;
a[a_val].type = CKA_MODULUS;
a[a_val].value = m.data;
a[a_val].value_len = m.size;
a_val++;
a[a_val].type = CKA_PUBLIC_EXPONENT;
a[a_val].value = e.data;
a[a_val].value_len = e.size;
a_val++;
a[a_val].type = CKA_PRIVATE_EXPONENT;
a[a_val].value = d.data;
a[a_val].value_len = d.size;
a_val++;
a[a_val].type = CKA_PRIME_1;
a[a_val].value = p.data;
a[a_val].value_len = p.size;
a_val++;
a[a_val].type = CKA_PRIME_2;
a[a_val].value = q.data;
a[a_val].value_len = q.size;
a_val++;
a[a_val].type = CKA_COEFFICIENT;
a[a_val].value = u.data;
a[a_val].value_len = u.size;
a_val++;
a[a_val].type = CKA_EXPONENT_1;
a[a_val].value = exp1.data;
a[a_val].value_len = exp1.size;
a_val++;
a[a_val].type = CKA_EXPONENT_2;
a[a_val].value = exp2.data;
a[a_val].value_len = exp2.size;
a_val++;
break;
}
case GNUTLS_PK_DSA:
{
ret = gnutls_x509_privkey_export_dsa_raw (key, &p, &q, &g, &y, &x);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
type = CKK_DSA;
a[a_val].type = CKA_PRIME;
a[a_val].value = p.data;
a[a_val].value_len = p.size;
a_val++;
a[a_val].type = CKA_SUBPRIME;
a[a_val].value = q.data;
a[a_val].value_len = q.size;
a_val++;
a[a_val].type = CKA_BASE;
a[a_val].value = g.data;
a[a_val].value_len = g.size;
a_val++;
a[a_val].type = CKA_VALUE;
a[a_val].value = x.data;
a[a_val].value_len = x.size;
a_val++;
break;
}
case GNUTLS_PK_EC:
{
ret = _gnutls_x509_write_ecc_params(&key->params, &p);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = _gnutls_mpi_dprint_lz(&key->params.params[ECC_K], &x);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
type = CKK_ECDSA;
a[a_val].type = CKA_EC_PARAMS;
a[a_val].value = p.data;
a[a_val].value_len = p.size;
a_val++;
a[a_val].type = CKA_VALUE;
a[a_val].value = x.data;
a[a_val].value_len = x.size;
a_val++;
break;
}
default:
gnutls_assert ();
ret = GNUTLS_E_INVALID_REQUEST;
goto cleanup;
}
rv = pkcs11_create_object (module, pks, a, a_val, &obj);
if (rv != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("pkcs11: %s\n", pkcs11_strerror (rv));
ret = pkcs11_rv_to_err (rv);
goto cleanup;
}
ret = 0;
cleanup:
switch (pk)
{
case GNUTLS_PK_RSA:
{
gnutls_free (m.data);
gnutls_free (e.data);
gnutls_free (d.data);
gnutls_free (p.data);
gnutls_free (q.data);
gnutls_free (u.data);
gnutls_free (exp1.data);
gnutls_free (exp2.data);
break;
}
case GNUTLS_PK_DSA:
{
gnutls_free (p.data);
gnutls_free (q.data);
gnutls_free (g.data);
gnutls_free (y.data);
gnutls_free (x.data);
break;
}
case GNUTLS_PK_EC:
{
gnutls_free (p.data);
gnutls_free (x.data);
break;
}
default:
gnutls_assert ();
ret = GNUTLS_E_INVALID_REQUEST;
break;
}
if (pks != 0)
pkcs11_close_session (module, pks);
return ret;
}
|
↓
|
read_pkcs_schema_params
|
15
|
64
|
146
|
x509/privkey_pkcs8.c
|
static int
read_pkcs_schema_params (schema_id * schema, const char *password,
const opaque * data, int data_size,
struct pbkdf2_params *kdf_params,
struct pbe_enc_params *enc_params)
{
ASN1_TYPE pbes2_asn = ASN1_TYPE_EMPTY;
int result;
gnutls_datum_t tmp;
switch (*schema)
{
case PBES2_GENERIC:
/* Now check the key derivation and the encryption
* functions.
*/
if ((result =
asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-5-PBES2-params",
&pbes2_asn)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Decode the parameters.
*/
result = asn1_der_decoding (&pbes2_asn, data, data_size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
tmp.data = (opaque *) data;
tmp.size = data_size;
result = read_pbkdf2_params (pbes2_asn, &tmp, kdf_params);
if (result < 0)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
result = read_pbe_enc_params (pbes2_asn, &tmp, enc_params);
if (result < 0)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
asn1_delete_structure (&pbes2_asn);
result = cipher_to_schema (enc_params->cipher);
if (result < 0)
{
gnutls_assert ();
goto error;
}
*schema = result;
return 0;
case PKCS12_3DES_SHA1:
case PKCS12_ARCFOUR_SHA1:
case PKCS12_RC2_40_SHA1:
if ((*schema) == PKCS12_3DES_SHA1)
{
enc_params->cipher = GNUTLS_CIPHER_3DES_CBC;
enc_params->iv_size = 8;
}
else if ((*schema) == PKCS12_ARCFOUR_SHA1)
{
enc_params->cipher = GNUTLS_CIPHER_ARCFOUR_128;
enc_params->iv_size = 0;
}
else if ((*schema) == PKCS12_RC2_40_SHA1)
{
enc_params->cipher = GNUTLS_CIPHER_RC2_40_CBC;
enc_params->iv_size = 8;
}
if ((result =
asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-PbeParams",
&pbes2_asn)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Decode the parameters.
*/
result = asn1_der_decoding (&pbes2_asn, data, data_size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
result = read_pkcs12_kdf_params (pbes2_asn, kdf_params);
if (result < 0)
{
gnutls_assert ();
goto error;
}
if (enc_params->iv_size)
{
result =
_gnutls_pkcs12_string_to_key (2 /*IV*/, kdf_params->salt,
kdf_params->salt_size,
kdf_params->iter_count, password,
enc_params->iv_size,
enc_params->iv);
if (result < 0)
{
gnutls_assert ();
goto error;
}
}
asn1_delete_structure (&pbes2_asn);
return 0;
default:
gnutls_assert ();
} /* switch */
return GNUTLS_E_UNKNOWN_CIPHER_TYPE;
error:
asn1_delete_structure (&pbes2_asn);
return result;
}
|
↓
|
_gnutls_pkcs1_rsa_decrypt
|
15
|
51
|
108
|
gnutls_pk.c
|
int
_gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext,
const gnutls_datum_t * ciphertext,
gnutls_pk_params_st* params,
unsigned btype)
{
unsigned int k, i;
int ret;
size_t esize, mod_bits;
mod_bits = _gnutls_mpi_get_nbits (params->params[0]);
k = mod_bits / 8;
if (mod_bits % 8 != 0)
k++;
esize = ciphertext->size;
if (esize != k)
{
gnutls_assert ();
return GNUTLS_E_PK_DECRYPTION_FAILED;
}
/* we can use btype to see if the private key is
* available.
*/
if (btype == 2)
{
ret =
_gnutls_pk_decrypt (GNUTLS_PK_RSA, plaintext, ciphertext, params);
}
else
{
ret =
_gnutls_pk_encrypt (GNUTLS_PK_RSA, plaintext, ciphertext, params);
}
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* EB = 00||BT||PS||00||D
* (use block type 'btype')
*
* From now on, return GNUTLS_E_DECRYPTION_FAILED on errors, to
* avoid attacks similar to the one described by Bleichenbacher in:
* "Chosen Ciphertext Attacks against Protocols Based on RSA
* Encryption Standard PKCS #1".
*/
if (plaintext->data[0] != 0 || plaintext->data[1] != btype)
{
gnutls_assert ();
_gnutls_free_datum (plaintext);
return GNUTLS_E_DECRYPTION_FAILED;
}
ret = GNUTLS_E_DECRYPTION_FAILED;
switch (btype)
{
case 2:
for (i = 2; i < plaintext->size; i++)
{
if (plaintext->data[i] == 0)
{
ret = 0;
break;
}
}
break;
case 1:
for (i = 2; i < plaintext->size; i++)
{
if (plaintext->data[i] == 0 && i > 2)
{
ret = 0;
break;
}
if (plaintext->data[i] != 0xff)
{
_gnutls_handshake_log ("PKCS #1 padding error");
_gnutls_free_datum (plaintext);
/* PKCS #1 padding error. Don't use
GNUTLS_E_PKCS1_WRONG_PAD here. */
break;
}
}
break;
default:
gnutls_assert ();
_gnutls_free_datum (plaintext);
break;
}
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (plaintext);
return GNUTLS_E_DECRYPTION_FAILED;
}
i++;
memmove (plaintext->data, &plaintext->data[i], esize - i);
plaintext->size = esize - i;
return 0;
}
|
↓
|
gen_group
|
15
|
84
|
161
|
nettle/mpi.c
|
inline static int
gen_group (mpz_t * prime, mpz_t * generator, unsigned int nbits, unsigned int *q_bits)
{
mpz_t q, w, r;
unsigned int p_bytes = nbits / 8;
opaque *buffer = NULL;
unsigned int q_bytes, w_bytes, r_bytes, w_bits;
int ret;
/* security level enforcement.
* Values for q are selected according to ECRYPT II recommendations.
*/
q_bytes = _gnutls_pk_bits_to_subgroup_bits (nbits);
q_bytes /= 8;
if (q_bytes == 0)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (nbits % 8 != 0)
p_bytes++;
w_bits = nbits - q_bytes * 8;
w_bytes = w_bits / 8;
if (w_bits % 8 != 0)
w_bytes++;
_gnutls_debug_log
("Generating group of prime of %u bits and format of 2wq+1. q_size=%u bits\n",
nbits, q_bytes * 8);
buffer = gnutls_malloc (p_bytes); /* p_bytes > q_bytes */
if (buffer == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
mpz_init (q);
mpz_init (w);
mpz_init (r);
/* search for a prime. We are not that unlucky so search
* forever.
*/
for (;;)
{
ret = _gnutls_rnd (GNUTLS_RND_RANDOM, buffer, w_bytes);
if (ret < 0)
{
gnutls_assert ();
goto fail;
}
nettle_mpz_set_str_256_u (w, w_bytes, buffer);
/* always odd */
mpz_setbit (w, 0);
ret = mpz_probab_prime_p (w, PRIME_CHECK_PARAM);
if (ret > 0)
{
break;
}
}
/* now generate q of size p_bytes - w_bytes */
_gnutls_debug_log
("Found prime w of %u bits. Will look for q of %u bits...\n",
wrap_nettle_mpi_get_nbits (&w), q_bytes*8);
for (;;)
{
ret = _gnutls_rnd (GNUTLS_RND_RANDOM, buffer, q_bytes);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
nettle_mpz_set_str_256_u (q, q_bytes, buffer);
/* always odd */
mpz_setbit (q, 0);
ret = mpz_probab_prime_p (q, PRIME_CHECK_PARAM);
if (ret == 0)
{
continue;
}
/* check if 2wq+1 is prime */
mpz_mul_ui (*prime, w, 2);
mpz_mul (*prime, *prime, q);
mpz_add_ui (*prime, *prime, 1);
ret = mpz_probab_prime_p (*prime, PRIME_CHECK_PARAM);
if (ret > 0)
{
break;
}
}
*q_bits = wrap_nettle_mpi_get_nbits (&q);
_gnutls_debug_log ("Found prime q of %u bits. Looking for generator...\n",
*q_bits);
/* finally a prime! Let calculate generator
*/
/* c = r^((p-1)/q), r == random
* c = r^(2w)
* if c!=1 c is the generator for the subgroup of order q-1
*
*/
r_bytes = p_bytes;
mpz_mul_ui (w, w, 2); /* w = w*2 */
mpz_fdiv_r (w, w, *prime);
for (;;)
{
ret = _gnutls_rnd (GNUTLS_RND_NONCE, buffer, r_bytes);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
nettle_mpz_set_str_256_u (r, r_bytes, buffer);
mpz_fdiv_r (r, r, *prime);
/* check if r^w mod n != 1 mod n */
mpz_powm (*generator, r, w, *prime);
if (mpz_cmp_ui (*generator, 1) == 0)
continue;
else
break;
}
_gnutls_debug_log ("Found generator g of %u bits\n",
wrap_nettle_mpi_get_nbits (generator));
_gnutls_debug_log ("Prime n is %u bits\n",
wrap_nettle_mpi_get_nbits (prime));
ret = 0;
goto exit;
fail:
mpz_clear (*prime);
mpz_clear (*generator);
exit:
mpz_clear (q);
mpz_clear (w);
mpz_clear (r);
gnutls_free (buffer);
return ret;
}
|
↓
|
_gnutls_key_fingerprint_randomart
|
15
|
70
|
104
|
extras/randomart.c
|
char *
_gnutls_key_fingerprint_randomart (uint8_t * dgst_raw, u_int dgst_raw_len,
const char *key_type, unsigned int key_size,
const char* prefix)
{
/*
* Chars to be used after each other every time the worm
* intersects with itself. Matter of taste.
*/
const char augmentation_string[] = " .o+=*BOX@%&#/^SE";
char *retval, *p;
uint8_t field[FLDSIZE_X][FLDSIZE_Y];
u_int i, b;
int x, y;
const size_t len = sizeof(augmentation_string) - 2;
int prefix_len = 0;
if (prefix)
prefix_len = strlen(prefix);
retval = gnutls_calloc (1, (FLDSIZE_X + 3 + prefix_len) * (FLDSIZE_Y + 2));
if (retval == NULL)
{
gnutls_assert();
return NULL;
}
/* initialize field */
memset (field, 0, FLDSIZE_X * FLDSIZE_Y * sizeof (char));
x = FLDSIZE_X / 2;
y = FLDSIZE_Y / 2;
/* process raw key */
for (i = 0; i < dgst_raw_len; i++)
{
int input;
/* each byte conveys four 2-bit move commands */
input = dgst_raw[i];
for (b = 0; b < 4; b++)
{
/* evaluate 2 bit, rest is shifted later */
x += (input & 0x1) ? 1 : -1;
y += (input & 0x2) ? 1 : -1;
/* assure we are still in bounds */
x = MAX (x, 0);
y = MAX (y, 0);
x = MIN (x, FLDSIZE_X - 1);
y = MIN (y, FLDSIZE_Y - 1);
/* augment the field */
if (field[x][y] < len - 2)
field[x][y]++;
input = input >> 2;
}
}
/* mark starting point and end point */
field[FLDSIZE_X / 2][FLDSIZE_Y / 2] = len - 1;
field[x][y] = len;
/* fill in retval */
if (prefix_len)
snprintf (retval, FLDSIZE_X + prefix_len, "%s+--[%4s %4u]", prefix, key_type, key_size);
else
snprintf (retval, FLDSIZE_X, "+--[%4s %4u]", key_type, key_size);
p = strchr (retval, '\0');
/* output upper border */
for (i = p - retval - 1; i < FLDSIZE_X + prefix_len; i++)
*p++ = '-';
*p++ = '+';
*p++ = '\n';
if (prefix_len)
{
memcpy(p, prefix, prefix_len);
p += prefix_len;
}
/* output content */
for (y = 0; y < FLDSIZE_Y; y++)
{
*p++ = '|';
for (x = 0; x < FLDSIZE_X; x++)
*p++ = augmentation_string[MIN (field[x][y], len)];
*p++ = '|';
*p++ = '\n';
if (prefix_len)
{
memcpy(p, prefix, prefix_len);
p += prefix_len;
}
}
/* output lower border */
*p++ = '+';
for (i = 0; i < FLDSIZE_X; i++)
*p++ = '-';
*p++ = '+';
return retval;
}
|
↓
|
gnutls_ocsp_resp_verify
|
15
|
63
|
122
|
x509/ocsp.c
|
int
gnutls_ocsp_resp_verify (gnutls_ocsp_resp_t resp,
gnutls_x509_trust_list_t trustlist,
unsigned *verify,
int flags)
{
gnutls_x509_crt_t signercert = NULL;
int rc;
/* Algorithm:
1. Find signer cert.
1a. Search in OCSP response Certificate field for responderID.
1b. Verify that signer cert is trusted.
2a. It is in trustlist?
2b. It has OCSP key usage and directly signed by a CA in trustlist?
3. Verify signature of Basic Response using public key from signer cert.
*/
signercert = find_signercert (resp);
if (!signercert)
{
/* XXX Search in trustlist for certificate matching
responderId as well? */
gnutls_assert ();
*verify = GNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND;
rc = GNUTLS_E_SUCCESS;
goto done;
}
/* Either the signer is directly trusted (i.e., in trustlist) or it
is directly signed by something in trustlist and has proper OCSP
extkeyusage. */
rc = _gnutls_trustlist_inlist (trustlist, signercert);
if (rc < 0)
{
gnutls_assert ();
goto done;
}
if (rc == 1)
{
/* not in trustlist, need to verify signature and bits */
gnutls_x509_crt_t issuer;
unsigned vtmp;
char oidtmp[sizeof (GNUTLS_KP_OCSP_SIGNING)];
size_t oidsize;
int indx;
gnutls_assert ();
rc = gnutls_x509_trust_list_get_issuer (trustlist, signercert,
&issuer, 0);
if (rc != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
*verify = GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER;
rc = GNUTLS_E_SUCCESS;
goto done;
}
rc = gnutls_x509_crt_verify (signercert, &issuer, 1, 0, &vtmp);
if (rc != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
goto done;
}
if (vtmp != 0)
{
gnutls_assert ();
if (vtmp & GNUTLS_CERT_INSECURE_ALGORITHM)
*verify = GNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM;
else if (vtmp & GNUTLS_CERT_NOT_ACTIVATED)
*verify = GNUTLS_OCSP_VERIFY_CERT_NOT_ACTIVATED;
else if (vtmp & GNUTLS_CERT_EXPIRED)
*verify = GNUTLS_OCSP_VERIFY_CERT_EXPIRED;
else
*verify = GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER;
rc = GNUTLS_E_SUCCESS;
goto done;
}
for (indx = 0; ; indx++)
{
oidsize = sizeof (oidtmp);
rc = gnutls_x509_crt_get_key_purpose_oid (signercert, indx,
oidtmp, &oidsize,
NULL);
if (rc == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
{
gnutls_assert ();
*verify = GNUTLS_OCSP_VERIFY_SIGNER_KEYUSAGE_ERROR;
rc = GNUTLS_E_SUCCESS;
goto done;
}
else if (rc == GNUTLS_E_SHORT_MEMORY_BUFFER)
{
gnutls_assert ();
continue;
}
else if (rc != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
goto done;
}
if (memcmp (oidtmp, GNUTLS_KP_OCSP_SIGNING, oidsize) != 0)
{
gnutls_assert ();
continue;
}
break;
}
}
rc = gnutls_ocsp_resp_verify_direct (resp, signercert, verify, flags);
done:
gnutls_x509_crt_deinit (signercert);
return rc;
}
|
↓
|
gnutls_x509_crl_list_import
|
15
|
57
|
113
|
x509/crl.c
|
int
gnutls_x509_crl_list_import (gnutls_x509_crl_t * crls,
unsigned int *crl_max,
const gnutls_datum_t * data,
gnutls_x509_crt_fmt_t format, unsigned int flags)
{
int size;
const char *ptr;
gnutls_datum_t tmp;
int ret, nocopy = 0;
unsigned int count = 0, j;
if (format == GNUTLS_X509_FMT_DER)
{
if (*crl_max < 1)
{
*crl_max = 1;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
count = 1; /* import only the first one */
ret = gnutls_x509_crl_init (&crls[0]);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
ret = gnutls_x509_crl_import (crls[0], data, format);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
*crl_max = 1;
return 1;
}
/* move to the certificate
*/
ptr = memmem (data->data, data->size,
PEM_CRL_SEP, sizeof (PEM_CRL_SEP) - 1);
if (ptr == NULL)
{
gnutls_assert ();
return GNUTLS_E_BASE64_DECODING_ERROR;
}
count = 0;
do
{
if (count >= *crl_max)
{
if (!(flags & GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED))
break;
else
nocopy = 1;
}
if (!nocopy)
{
ret = gnutls_x509_crl_init (&crls[count]);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
tmp.data = (void *) ptr;
tmp.size = data->size - (ptr - (char *) data->data);
ret =
gnutls_x509_crl_import (crls[count], &tmp, GNUTLS_X509_FMT_PEM);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
}
/* now we move ptr after the pem header
*/
ptr++;
/* find the next certificate (if any)
*/
size = data->size - (ptr - (char *) data->data);
if (size > 0)
{
ptr = memmem (ptr, size, PEM_CRL_SEP, sizeof (PEM_CRL_SEP) - 1);
}
else
ptr = NULL;
count++;
}
while (ptr != NULL);
*crl_max = count;
if (nocopy == 0)
return count;
else
return GNUTLS_E_SHORT_MEMORY_BUFFER;
error:
for (j = 0; j < count; j++)
gnutls_x509_crl_deinit (crls[j]);
return ret;
}
|
↓
|
_rndegd_read
|
15
|
54
|
87
|
nettle/egd.c
|
int
_rndegd_read (int *fd, void *_output, size_t _length)
{
int n;
uint8_t buffer[256 + 2];
int nbytes;
int do_restart = 0;
unsigned char *output = _output;
size_t length = _length;
if (!length)
return 0;
restart:
if (*fd == -1 || do_restart)
*fd = _rndegd_connect_socket ();
do_restart = 0;
nbytes = length < 255 ? length : 255;
/* First time we do it with a non blocking request */
buffer[0] = 1; /* non blocking */
buffer[1] = nbytes;
if (do_write (*fd, buffer, 2) == -1)
_gnutls_debug_log ("can't write to the EGD: %s\n", strerror (errno));
n = do_read (*fd, buffer, 1);
if (n == -1)
{
_gnutls_debug_log ("read error on EGD: %s\n", strerror (errno));
do_restart = 1;
goto restart;
}
n = buffer[0];
if (n)
{
n = do_read (*fd, buffer, n);
if (n == -1)
{
_gnutls_debug_log ("read error on EGD: %s\n", strerror (errno));
do_restart = 1;
goto restart;
}
if (n > length)
{
_gnutls_debug_log ("read error on EGD: returned more bytes!\n");
n = length;
}
memcpy (output, buffer, n);
output += n;
length -= n;
}
while (length)
{
nbytes = length < 255 ? length : 255;
buffer[0] = 2; /* blocking */
buffer[1] = nbytes;
if (do_write (*fd, buffer, 2) == -1)
_gnutls_debug_log ("can't write to the EGD: %s\n", strerror (errno));
n = do_read (*fd, buffer, nbytes);
if (n == -1)
{
_gnutls_debug_log ("read error on EGD: %s\n", strerror (errno));
do_restart = 1;
goto restart;
}
if (n > length)
{
_gnutls_debug_log ("read error on EGD: returned more bytes!\n");
n = length;
}
memcpy (output, buffer, n);
output += n;
length -= n;
}
return _length; /* success */
}
|
↓
|
_cdk_keydb_get_sk_byusage
|
15
|
50
|
86
|
opencdk/keydb.c
|
cdk_error_t
_cdk_keydb_get_sk_byusage (cdk_keydb_hd_t hd, const char *name,
cdk_seckey_t * ret_sk, int usage)
{
cdk_kbnode_t knode = NULL;
cdk_kbnode_t node, sk_node, pk_node;
cdk_pkt_seckey_t sk;
cdk_error_t rc;
const char *s;
int pkttype;
cdk_keydb_search_t st;
if (!ret_sk || !usage)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd)
{
gnutls_assert ();
return CDK_Error_No_Keyring;
}
*ret_sk = NULL;
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_AUTO, (char *) name);
if (rc)
{
gnutls_assert ();
return rc;
}
rc = cdk_keydb_search (st, hd, &knode);
if (rc)
{
gnutls_assert ();
return rc;
}
cdk_keydb_search_release (st);
sk_node = keydb_find_byusage (knode, usage, 0);
if (!sk_node)
{
cdk_kbnode_release (knode);
gnutls_assert ();
return CDK_Unusable_Key;
}
/* We clone the node with the secret key to avoid that the
packet will be released. */
_cdk_kbnode_clone (sk_node);
sk = sk_node->pkt->pkt.secret_key;
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype == CDK_PKT_USER_ID)
{
s = node->pkt->pkt.user_id->name;
if (sk && !sk->pk->uid && _cdk_memistr (s, strlen (s), name))
{
_cdk_copy_userid (&sk->pk->uid, node->pkt->pkt.user_id);
break;
}
}
}
/* To find the self signature, we need the primary public key because
the selected secret key might be different from the primary key. */
pk_node = cdk_kbnode_find (knode, CDK_PKT_SECRET_KEY);
if (!pk_node)
{
cdk_kbnode_release (knode);
gnutls_assert ();
return CDK_Unusable_Key;
}
node = find_selfsig_node (knode, pk_node->pkt->pkt.secret_key->pk);
if (sk->pk->uid && node)
_cdk_copy_signature (&sk->pk->uid->selfsig, node->pkt->pkt.signature);
/* We only release the outer packet. */
_cdk_pkt_detach_free (sk_node->pkt, &pkttype, (void *) &sk);
cdk_kbnode_release (knode);
*ret_sk = sk;
return rc;
}
|
↓
|
_gnutls_psk_pwd_find_entry
|
15
|
46
|
99
|
auth/psk_passwd.c
|
int
_gnutls_psk_pwd_find_entry (gnutls_session_t session, char *username,
gnutls_datum_t * psk)
{
gnutls_psk_server_credentials_t cred;
FILE *fd;
char line[2 * 1024];
unsigned i, len;
int ret;
cred = (gnutls_psk_server_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_PSK, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* if the callback which sends the parameters is
* set, use it.
*/
if (cred->pwd_callback != NULL)
{
ret = cred->pwd_callback (session, username, psk);
if (ret == 1)
{ /* the user does not exist */
ret = _randomize_psk (psk);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_SRP_PWD_ERROR;
}
return 0;
}
/* The callback was not set. Proceed.
*/
if (cred->password_file == NULL)
{
gnutls_assert ();
return GNUTLS_E_SRP_PWD_ERROR;
}
/* Open the selected password file.
*/
fd = fopen (cred->password_file, "r");
if (fd == NULL)
{
gnutls_assert ();
return GNUTLS_E_SRP_PWD_ERROR;
}
len = strlen (username);
while (fgets (line, sizeof (line), fd) != NULL)
{
/* move to first ':' */
i = 0;
while ((line[i] != ':') && (line[i] != '\0') && (i < sizeof (line)))
{
i++;
}
if (strncmp (username, line, MAX (i, len)) == 0)
{
ret = pwd_put_values (psk, line);
fclose (fd);
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_SRP_PWD_ERROR;
}
return 0;
}
}
fclose (fd);
/* user was not found. Fake him.
* the last index found and randomize the entry.
*/
ret = _randomize_psk (psk);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
|
↓
|
gnutls_ocsp_req_get_cert_id
|
15
|
45
|
85
|
x509/ocsp.c
|
int
gnutls_ocsp_req_get_cert_id (gnutls_ocsp_req_t req,
unsigned indx,
gnutls_digest_algorithm_t *digest,
gnutls_datum_t *issuer_name_hash,
gnutls_datum_t *issuer_key_hash,
gnutls_datum_t *serial_number)
{
gnutls_datum_t sa;
char name[ASN1_MAX_NAME_SIZE];
int ret;
if (req == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
snprintf (name, sizeof (name),
"tbsRequest.requestList.?%u.reqCert.hashAlgorithm.algorithm",
indx + 1);
ret = _gnutls_x509_read_value (req->req, name, &sa, 0);
if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
else if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_x509_oid2digest_algorithm (sa.data);
_gnutls_free_datum (&sa);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (digest)
*digest = ret;
if (issuer_name_hash)
{
snprintf (name, sizeof (name),
"tbsRequest.requestList.?%u.reqCert.issuerNameHash", indx + 1);
ret = _gnutls_x509_read_value (req->req, name, issuer_name_hash, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
return ret;
}
}
if (issuer_key_hash)
{
snprintf (name, sizeof (name),
"tbsRequest.requestList.?%u.reqCert.issuerKeyHash", indx + 1);
ret = _gnutls_x509_read_value (req->req, name, issuer_key_hash, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
if (issuer_name_hash)
gnutls_free (issuer_name_hash->data);
return ret;
}
}
if (serial_number)
{
snprintf (name, sizeof (name),
"tbsRequest.requestList.?%u.reqCert.serialNumber", indx + 1);
ret = _gnutls_x509_read_value (req->req, name, serial_number, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
if (issuer_name_hash)
gnutls_free (issuer_name_hash->data);
if (issuer_key_hash)
gnutls_free (issuer_key_hash->data);
return ret;
}
}
return GNUTLS_E_SUCCESS;
}
|
↓
|
_cdk_keydb_get_pk_byusage
|
15
|
45
|
73
|
opencdk/keydb.c
|
cdk_error_t
_cdk_keydb_get_pk_byusage (cdk_keydb_hd_t hd, const char *name,
cdk_pubkey_t * ret_pk, int usage)
{
cdk_kbnode_t knode, node, pk_node;
cdk_pkt_pubkey_t pk;
const char *s;
cdk_error_t rc;
cdk_keydb_search_t st;
if (!ret_pk || !usage)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (!hd)
{
gnutls_assert ();
return CDK_Error_No_Keyring;
}
*ret_pk = NULL;
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_AUTO, (char *) name);
if (!rc)
rc = cdk_keydb_search (st, hd, &knode);
if (rc)
{
gnutls_assert ();
return rc;
}
cdk_keydb_search_release (st);
node = keydb_find_byusage (knode, usage, 1);
if (!node)
{
cdk_kbnode_release (knode);
gnutls_assert ();
return CDK_Unusable_Key;
}
pk = NULL;
_cdk_copy_pubkey (&pk, node->pkt->pkt.public_key);
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype == CDK_PKT_USER_ID)
{
s = node->pkt->pkt.user_id->name;
if (pk && !pk->uid && _cdk_memistr (s, strlen (s), name))
{
_cdk_copy_userid (&pk->uid, node->pkt->pkt.user_id);
break;
}
}
}
/* Same as in the sk code, the selected key can be a sub key
and thus we need the primary key to find the self sig. */
pk_node = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (!pk_node)
{
cdk_kbnode_release (knode);
gnutls_assert ();
return CDK_Unusable_Key;
}
node = find_selfsig_node (knode, pk_node->pkt->pkt.public_key);
if (pk->uid && node)
_cdk_copy_signature (&pk->uid->selfsig, node->pkt->pkt.signature);
cdk_kbnode_release (knode);
*ret_pk = pk;
return rc;
}
|
↓
|
_pkcs11_traverse_tokens
|
15
|
43
|
88
|
pkcs11.c
|
int
_pkcs11_traverse_tokens (find_func_t find_func, void *input,
struct p11_kit_uri *info, unsigned int flags)
{
ck_rv_t rv;
int found = 0, x, z, ret;
ck_session_handle_t pks = 0;
struct ck_function_list *module = NULL;
for (x = 0; x < active_providers; x++)
{
module = providers[x].module;
for (z = 0; z < providers[x].nslots; z++)
{
struct token_info tinfo;
ret = GNUTLS_E_PKCS11_ERROR;
if (pkcs11_get_token_info (module, providers[x].slots[z],
&tinfo.tinfo) != CKR_OK)
{
continue;
}
tinfo.sid = providers[x].slots[z];
tinfo.prov = &providers[x];
if (pkcs11_get_slot_info (module, providers[x].slots[z],
&tinfo.sinfo) != CKR_OK)
{
continue;
}
rv = (module)->C_OpenSession (providers[x].slots[z],
((flags & SESSION_WRITE)
? CKF_RW_SESSION : 0) |
CKF_SERIAL_SESSION, NULL, NULL, &pks);
if (rv != CKR_OK)
{
continue;
}
if (flags & SESSION_LOGIN)
{
ret = pkcs11_login (module, pks, &tinfo, info, (flags & SESSION_SO) ? 1 : 0);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
}
ret = find_func (module, pks, &tinfo, &providers[x].info, input);
if (ret == 0)
{
found = 1;
goto finish;
}
else
{
pkcs11_close_session (module, pks);
pks = 0;
}
}
}
finish:
/* final call */
if (found == 0)
{
if (module)
ret = find_func (module, pks, NULL, NULL, input);
else
ret = gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
}
else
{
ret = 0;
}
if (pks != 0 && module != NULL)
{
pkcs11_close_session (module, pks);
}
return ret;
}
|
↓
|
check_if_ca
|
15
|
41
|
95
|
x509/verify.c
|
static int
check_if_ca (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer,
unsigned int flags)
{
gnutls_datum_t cert_signed_data = { NULL, 0 };
gnutls_datum_t issuer_signed_data = { NULL, 0 };
gnutls_datum_t cert_signature = { NULL, 0 };
gnutls_datum_t issuer_signature = { NULL, 0 };
int result;
/* Check if the issuer is the same with the
* certificate. This is added in order for trusted
* certificates to be able to verify themselves.
*/
result =
_gnutls_x509_get_signed_data (issuer->cert, "tbsCertificate",
&issuer_signed_data);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result =
_gnutls_x509_get_signed_data (cert->cert, "tbsCertificate",
&cert_signed_data);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result =
_gnutls_x509_get_signature (issuer->cert, "signature", &issuer_signature);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
result =
_gnutls_x509_get_signature (cert->cert, "signature", &cert_signature);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
/* If the subject certificate is the same as the issuer
* return true.
*/
if (!(flags & GNUTLS_VERIFY_DO_NOT_ALLOW_SAME))
if (cert_signed_data.size == issuer_signed_data.size)
{
if ((memcmp (cert_signed_data.data, issuer_signed_data.data,
cert_signed_data.size) == 0) &&
(cert_signature.size == issuer_signature.size) &&
(memcmp (cert_signature.data, issuer_signature.data,
cert_signature.size) == 0))
{
result = 1;
goto cleanup;
}
}
result = gnutls_x509_crt_get_ca_status (issuer, NULL);
if (result == 1)
{
result = 1;
goto cleanup;
}
/* Handle V1 CAs that do not have a basicConstraint, but accept
these certs only if the appropriate flags are set. */
else if ((result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) &&
((flags & GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT) ||
(!(flags & GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT) &&
(gnutls_x509_crt_check_issuer (issuer, issuer) == 1))))
{
gnutls_assert ();
result = 1;
goto cleanup;
}
else
gnutls_assert ();
result = 0;
cleanup:
_gnutls_free_datum (&cert_signed_data);
_gnutls_free_datum (&issuer_signed_data);
_gnutls_free_datum (&cert_signature);
_gnutls_free_datum (&issuer_signature);
return result;
}
|
↓
|
stream_filter_write
|
15
|
35
|
55
|
opencdk/stream.c
|
static cdk_error_t
stream_filter_write (cdk_stream_t s)
{
struct stream_filter_s *f;
cdk_error_t rc = 0;
assert (s);
if (s->flags.filtrated)
{
gnutls_assert ();
return CDK_Inv_Value;
}
for (f = s->filters; f; f = f->next)
{
if (!f->flags.enabled)
continue;
/* if there is no next filter, create the final output file */
_gnutls_read_log ("filter [write]: last filter=%d fname=%s\n",
f->next ? 1 : 0, s->fname);
if (!f->next && s->fname)
f->tmp = fopen (s->fname, "w+b");
else
f->tmp = _cdk_tmpfile ();
if (!f->tmp)
{
rc = CDK_File_Error;
break;
}
/* If there is no next filter, flush the cache. We also do this
when the next filter is the armor filter because this filter
is special and before it starts, all data should be written. */
if ((!f->next || f->next->type == fARMOR) && s->cache.size)
{
rc = stream_cache_flush (s, f->tmp);
if (rc)
break;
}
rc = f->fnct (f->opaque, f->ctl, s->fp, f->tmp);
_gnutls_read_log ("filter [write]: type=%d rc=%d\n", f->type, rc);
if (!rc)
rc = stream_fp_replace (s, &f->tmp);
if (!rc)
rc = cdk_stream_seek (s, 0);
if (rc)
{
_gnutls_read_log ("filter [close]: fd=%d\n", fileno (f->tmp));
fclose (f->tmp);
f->tmp = NULL;
break;
}
}
return rc;
}
|
↓
|
check_g_n
|
15
|
15
|
43
|
auth/srp.c
|
static int
check_g_n (const opaque * g, size_t n_g, const opaque * n, size_t n_n)
{
if ((n_n == sizeof (srp_params_3072) &&
memcmp (srp_params_3072, n, n_n) == 0) ||
(n_n == sizeof (srp_params_4096) &&
memcmp (srp_params_4096, n, n_n) == 0))
{
if (n_g != 1 || g[0] != srp3072_generator)
{
return gnutls_assert_val(GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER);
}
return 0;
}
if (n_g != 1 || g[0] != srp_generator)
{
gnutls_assert ();
return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
if (n_n == sizeof (srp_params_1024) &&
memcmp (srp_params_1024, n, n_n) == 0)
{
return 0;
}
if (n_n == sizeof (srp_params_1536) &&
memcmp (srp_params_1536, n, n_n) == 0)
{
return 0;
}
if (n_n == sizeof (srp_params_2048) &&
memcmp (srp_params_2048, n, n_n) == 0)
{
return 0;
}
gnutls_assert ();
return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
|
↓
|
_gnutls_handshake_client
|
14
|
56
|
128
|
gnutls_handshake.c
|
int
_gnutls_handshake_client (gnutls_session_t session)
{
int ret = 0;
#ifdef HANDSHAKE_DEBUG
char buf[64];
if (session->internals.resumed_security_parameters.session_id_size > 0)
_gnutls_handshake_log ("HSK[%p]: Ask to resume: %s\n", session,
_gnutls_bin2hex (session->
internals.resumed_security_parameters.session_id,
session->
internals.resumed_security_parameters.session_id_size,
buf, sizeof (buf), NULL));
#endif
switch (STATE)
{
case STATE0:
case STATE1:
ret = _gnutls_send_hello (session, AGAIN (STATE1));
STATE = STATE1;
IMED_RET ("send hello", ret, 1);
case STATE11:
if (IS_DTLS (session))
{
ret =
_gnutls_recv_handshake (session,
GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST,
OPTIONAL_PACKET, NULL);
STATE = STATE11;
IMED_RET ("recv hello verify", ret, 1);
if (ret == 1)
{
STATE = STATE0;
return 1;
}
}
case STATE2:
/* receive the server hello */
ret =
_gnutls_recv_handshake (session,
GNUTLS_HANDSHAKE_SERVER_HELLO,
MANDATORY_PACKET, NULL);
STATE = STATE2;
IMED_RET ("recv hello", ret, 1);
case STATE70:
if (session->security_parameters.do_recv_supplemental)
{
ret = _gnutls_recv_supplemental (session);
STATE = STATE70;
IMED_RET ("recv supplemental", ret, 1);
}
case STATE3:
/* RECV CERTIFICATE */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_server_certificate (session);
STATE = STATE3;
IMED_RET ("recv server certificate", ret, 1);
case STATE4:
/* receive the server key exchange */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_server_kx_message (session);
STATE = STATE4;
IMED_RET ("recv server kx message", ret, 1);
case STATE5:
/* receive the server certificate request - if any
*/
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_server_certificate_request (session);
STATE = STATE5;
IMED_RET ("recv server certificate request message", ret, 1);
case STATE6:
/* receive the server hello done */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret =
_gnutls_recv_handshake (session,
GNUTLS_HANDSHAKE_SERVER_HELLO_DONE,
MANDATORY_PACKET, NULL);
STATE = STATE6;
IMED_RET ("recv server hello done", ret, 1);
case STATE71:
if (session->security_parameters.do_send_supplemental)
{
ret = _gnutls_send_supplemental (session, AGAIN (STATE71));
STATE = STATE71;
IMED_RET ("send supplemental", ret, 0);
}
case STATE7:
/* send our certificate - if any and if requested
*/
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_send_client_certificate (session, AGAIN (STATE7));
STATE = STATE7;
IMED_RET ("send client certificate", ret, 0);
case STATE8:
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_send_client_kx_message (session, AGAIN (STATE8));
STATE = STATE8;
IMED_RET ("send client kx", ret, 0);
case STATE9:
/* send client certificate verify */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret =
_gnutls_send_client_certificate_verify (session, AGAIN (STATE9));
STATE = STATE9;
IMED_RET ("send client certificate verify", ret, 1);
STATE = STATE0;
default:
break;
}
return 0;
}
|
↓
|
_gnutls_parse_aia
|
14
|
50
|
91
|
x509/x509.c
|
static int
_gnutls_parse_aia (ASN1_TYPE src,
unsigned int seq,
int what,
gnutls_datum_t * data)
{
int len;
char nptr[ASN1_MAX_NAME_SIZE];
int result;
gnutls_datum_t d;
const char *oid = NULL;
seq++; /* 0->1, 1->2 etc */
switch (what)
{
case GNUTLS_IA_ACCESSMETHOD_OID:
snprintf (nptr, sizeof (nptr), "?%u.accessMethod", seq);
break;
case GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE:
snprintf (nptr, sizeof (nptr), "?%u.accessLocation", seq);
break;
case GNUTLS_IA_CAISSUERS_URI:
oid = GNUTLS_OID_AD_CAISSUERS;
/* fall through */
case GNUTLS_IA_OCSP_URI:
if (oid == NULL)
oid = GNUTLS_OID_AD_OCSP;
{
char *tmpoid[20];
snprintf (nptr, sizeof (nptr), "?%u.accessMethod", seq);
len = sizeof (tmpoid);
result = asn1_read_value (src, nptr, tmpoid, &len);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
if (len != strlen (oid) + 1 || memcmp (tmpoid, oid, len) != 0)
return GNUTLS_E_UNKNOWN_ALGORITHM;
}
/* fall through */
case GNUTLS_IA_URI:
snprintf (nptr, sizeof (nptr),
"?%u.accessLocation.uniformResourceIdentifier", seq);
break;
default:
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
len = 0;
result = asn1_read_value (src, nptr, NULL, &len);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
if (result != ASN1_MEM_ERROR)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
d.size = len;
d.data = gnutls_malloc (d.size);
if (d.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = asn1_read_value (src, nptr, d.data, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (d.data);
return _gnutls_asn2err (result);
}
if (data)
{
data->data = d.data;
data->size = d.size;
}
else
gnutls_free (d.data);
return GNUTLS_E_SUCCESS;
}
|
↓
|
read_pkcs11_pubkey
|
14
|
79
|
152
|
pkcs11.c
|
static int read_pkcs11_pubkey(struct ck_function_list *module,
ck_session_handle_t pks, ck_object_handle_t obj,
ck_key_type_t key_type, gnutls_datum_t * pubkey)
{
struct ck_attribute a[4];
opaque tmp1[2048];
opaque tmp2[2048];
int ret;
switch (key_type)
{
case CKK_RSA:
a[0].type = CKA_MODULUS;
a[0].value = tmp1;
a[0].value_len = sizeof (tmp1);
a[1].type = CKA_PUBLIC_EXPONENT;
a[1].value = tmp2;
a[1].value_len = sizeof (tmp2);
if (pkcs11_get_attribute_value (module, pks, obj, a, 2) == CKR_OK)
{
ret =
_gnutls_set_datum (&pubkey[0],
a[0].value, a[0].value_len);
if (ret >= 0)
ret =
_gnutls_set_datum (&pubkey
[1], a[1].value, a[1].value_len);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (&pubkey[1]);
_gnutls_free_datum (&pubkey[0]);
return GNUTLS_E_MEMORY_ERROR;
}
}
else
{
gnutls_assert ();
return GNUTLS_E_PKCS11_ERROR;
}
break;
case CKK_DSA:
a[0].type = CKA_PRIME;
a[0].value = tmp1;
a[0].value_len = sizeof (tmp1);
a[1].type = CKA_SUBPRIME;
a[1].value = tmp2;
a[1].value_len = sizeof (tmp2);
if (pkcs11_get_attribute_value (module, pks, obj, a, 2) == CKR_OK)
{
ret =
_gnutls_set_datum (&pubkey[0],
a[0].value, a[0].value_len);
if (ret >= 0)
ret =
_gnutls_set_datum (&pubkey
[1], a[1].value, a[1].value_len);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (&pubkey[1]);
_gnutls_free_datum (&pubkey[0]);
return GNUTLS_E_MEMORY_ERROR;
}
}
else
{
gnutls_assert ();
return GNUTLS_E_PKCS11_ERROR;
}
a[0].type = CKA_BASE;
a[0].value = tmp1;
a[0].value_len = sizeof (tmp1);
a[1].type = CKA_VALUE;
a[1].value = tmp2;
a[1].value_len = sizeof (tmp2);
if (pkcs11_get_attribute_value (module, pks, obj, a, 2) == CKR_OK)
{
ret =
_gnutls_set_datum (&pubkey[2],
a[0].value, a[0].value_len);
if (ret >= 0)
ret =
_gnutls_set_datum (&pubkey
[3], a[1].value, a[1].value_len);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (&pubkey[0]);
_gnutls_free_datum (&pubkey[1]);
_gnutls_free_datum (&pubkey[2]);
_gnutls_free_datum (&pubkey[3]);
return GNUTLS_E_MEMORY_ERROR;
}
}
else
{
gnutls_assert ();
return GNUTLS_E_PKCS11_ERROR;
}
break;
case CKK_ECDSA:
a[0].type = CKA_EC_PARAMS;
a[0].value = tmp1;
a[0].value_len = sizeof (tmp1);
a[1].type = CKA_EC_POINT;
a[1].value = tmp2;
a[1].value_len = sizeof (tmp2);
if (pkcs11_get_attribute_value (module, pks, obj, a, 2) == CKR_OK)
{
ret =
_gnutls_set_datum (&pubkey[0],
a[0].value, a[0].value_len);
if (ret >= 0)
ret =
_gnutls_set_datum (&pubkey
[1], a[1].value, a[1].value_len);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (&pubkey[1]);
_gnutls_free_datum (&pubkey[0]);
return GNUTLS_E_MEMORY_ERROR;
}
}
else
{
gnutls_assert ();
return GNUTLS_E_PKCS11_ERROR;
}
break;
default:
return gnutls_assert_val(GNUTLS_E_UNIMPLEMENTED_FEATURE);
}
return 0;
}
|
↓
|
_gnutls_proc_srp_server_kx
|
14
|
83
|
163
|
auth/srp.c
|
int
_gnutls_proc_srp_server_kx (gnutls_session_t session, opaque * data,
size_t _data_size)
{
uint8_t n_s;
uint16_t n_g, n_n, n_b;
size_t _n_g, _n_n, _n_b;
const uint8_t *data_n;
const uint8_t *data_g;
const uint8_t *data_s;
const uint8_t *data_b;
int i, ret;
opaque hd[SRP_MAX_HASH_SIZE];
char *username, *password;
ssize_t data_size = _data_size;
gnutls_srp_client_credentials_t cred;
extension_priv_data_t epriv;
srp_ext_st *priv;
ret = _gnutls_ext_get_session_data (session, GNUTLS_EXTENSION_SRP, &epriv);
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_UNKNOWN_SRP_USERNAME;
}
priv = epriv.ptr;
cred = (gnutls_srp_client_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_SRP, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if (priv->username == NULL)
{
username = cred->username;
password = cred->password;
}
else
{
username = priv->username;
password = priv->password;
}
if (username == NULL || password == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
i = 0;
/* Read N
*/
DECR_LEN (data_size, 2);
n_n = _gnutls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_n);
data_n = &data[i];
i += n_n;
/* Read G
*/
DECR_LEN (data_size, 2);
n_g = _gnutls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_g);
data_g = &data[i];
i += n_g;
/* Read salt
*/
DECR_LEN (data_size, 1);
n_s = data[i];
i += 1;
DECR_LEN (data_size, n_s);
data_s = &data[i];
i += n_s;
/* Read B
*/
DECR_LEN (data_size, 2);
n_b = _gnutls_read_uint16 (&data[i]);
i += 2;
DECR_LEN (data_size, n_b);
data_b = &data[i];
i += n_b;
_n_g = n_g;
_n_n = n_n;
_n_b = n_b;
if (_gnutls_mpi_scan_nz (&N, data_n, _n_n) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
if (_gnutls_mpi_scan_nz (&G, data_g, _n_g) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
if (_gnutls_mpi_scan_nz (&B, data_b, _n_b) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
/* Check if the g and n are from the SRP
* draft. Otherwise check if N is a prime and G
* a generator.
*/
if ((ret = check_g_n (data_g, _n_g, data_n, _n_n)) < 0)
{
_gnutls_audit_log (session, "SRP group parameters are not in the white list. Checking validity.\n");
if ((ret = group_check_g_n (session, G, N)) < 0)
{
gnutls_assert ();
return ret;
}
}
/* Checks if b % n == 0
*/
if ((ret = check_b_mod_n (B, N)) < 0)
{
gnutls_assert ();
return ret;
}
/* generate x = SHA(s | SHA(U | ":" | p))
* (or the equivalent using bcrypt)
*/
if ((ret =
_gnutls_calc_srp_x (username, password, (opaque *) data_s, n_s,
&_n_g, hd)) < 0)
{
gnutls_assert ();
return ret;
}
if (_gnutls_mpi_scan_nz (&session->key->x, hd, _n_g) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
return i; /* return the processed data
* needed in auth_srp_rsa.
*/
}
|
↓
|
_gnutls_ecc_curve_fill_params
|
14
|
70
|
114
|
gnutls_ecc.c
|
int _gnutls_ecc_curve_fill_params(gnutls_ecc_curve_t curve, gnutls_pk_params_st* params)
{
const gnutls_ecc_curve_entry_st *st;
uint8_t val[MAX_ECC_CURVE_SIZE];
size_t val_size;
int ret;
st = _gnutls_ecc_curve_get_params(curve);
if (st == NULL)
return gnutls_assert_val(GNUTLS_E_ECC_UNSUPPORTED_CURVE);
val_size = sizeof(val);
ret = _gnutls_hex2bin(st->prime, strlen(st->prime), val, &val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
ret = _gnutls_mpi_scan_nz(¶ms->params[ECC_PRIME], val, val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
params->params_nr++;
val_size = sizeof(val);
ret = _gnutls_hex2bin(st->order, strlen(st->order), val, &val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
ret = _gnutls_mpi_scan_nz(¶ms->params[ECC_ORDER], val, val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
params->params_nr++;
val_size = sizeof(val);
ret = _gnutls_hex2bin(st->A, strlen(st->A), val, &val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
ret = _gnutls_mpi_scan_nz(¶ms->params[ECC_A], val, val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
params->params_nr++;
val_size = sizeof(val);
ret = _gnutls_hex2bin(st->B, strlen(st->B), val, &val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
ret = _gnutls_mpi_scan_nz(¶ms->params[ECC_B], val, val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
params->params_nr++;
val_size = sizeof(val);
ret = _gnutls_hex2bin(st->Gx, strlen(st->Gx), val, &val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
ret = _gnutls_mpi_scan_nz(¶ms->params[ECC_GX], val, val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
params->params_nr++;
val_size = sizeof(val);
ret = _gnutls_hex2bin(st->Gy, strlen(st->Gy), val, &val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
ret = _gnutls_mpi_scan_nz(¶ms->params[ECC_GY], val, val_size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
params->params_nr++;
return 0;
cleanup:
gnutls_pk_params_release(params);
return ret;
}
|
↓
|
gnutls_x509_privkey_import_rsa_raw2
|
14
|
68
|
121
|
x509/privkey.c
|
int
gnutls_x509_privkey_import_rsa_raw2 (gnutls_x509_privkey_t key,
const gnutls_datum_t * m,
const gnutls_datum_t * e,
const gnutls_datum_t * d,
const gnutls_datum_t * p,
const gnutls_datum_t * q,
const gnutls_datum_t * u,
const gnutls_datum_t * e1,
const gnutls_datum_t * e2)
{
int ret;
size_t siz = 0;
if (key == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
gnutls_pk_params_init(&key->params);
siz = m->size;
if (_gnutls_mpi_scan_nz (&key->params.params[0], m->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
siz = e->size;
if (_gnutls_mpi_scan_nz (&key->params.params[1], e->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
siz = d->size;
if (_gnutls_mpi_scan_nz (&key->params.params[2], d->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
siz = p->size;
if (_gnutls_mpi_scan_nz (&key->params.params[3], p->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
siz = q->size;
if (_gnutls_mpi_scan_nz (&key->params.params[4], q->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
siz = u->size;
if (_gnutls_mpi_scan_nz (&key->params.params[5], u->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
if (e1 && e2)
{
siz = e1->size;
if (_gnutls_mpi_scan_nz (&key->params.params[6], e1->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
siz = e2->size;
if (_gnutls_mpi_scan_nz (&key->params.params[7], e2->data, siz))
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
key->params.params_nr++;
}
ret = _gnutls_pk_fixup (GNUTLS_PK_RSA, GNUTLS_IMPORT, &key->params);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = _gnutls_asn1_encode_privkey (GNUTLS_PK_RSA, &key->key, &key->params);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
key->params.params_nr = RSA_PRIVATE_PARAMS;
key->pk_algorithm = GNUTLS_PK_RSA;
return 0;
cleanup:
gnutls_pk_params_release(&key->params);
return ret;
}
|
↓
|
gen_dhe_server_kx
|
14
|
68
|
135
|
auth/dhe.c
|
static int
gen_dhe_server_kx (gnutls_session_t session, gnutls_buffer_st* data)
{
bigint_t g, p;
const bigint_t *mpis;
int ret = 0, data_size;
gnutls_pcert_st *apr_cert_list;
gnutls_privkey_t apr_pkey;
int apr_cert_list_length;
gnutls_datum_t signature = { NULL, 0 }, ddata;
gnutls_certificate_credentials_t cred;
gnutls_dh_params_t dh_params;
gnutls_sign_algorithm_t sign_algo;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
return ret;
}
if ((ret = _gnutls_auth_info_set (session, GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 0)) < 0)
{
gnutls_assert ();
return ret;
}
if (!_gnutls_session_is_ecc (session))
{
dh_params =
_gnutls_get_dh_params (cred->dh_params, cred->params_func, session);
mpis = _gnutls_dh_params_to_mpi (dh_params);
if (mpis == NULL)
{
gnutls_assert ();
return GNUTLS_E_NO_TEMPORARY_DH_PARAMS;
}
p = mpis[0];
g = mpis[1];
_gnutls_dh_set_group (session, g, p);
ret = _gnutls_dh_common_print_server_kx (session, g, p, dh_params->q_bits, data);
}
else
{
ret = _gnutls_ecdh_common_print_server_kx (session, data, _gnutls_session_ecc_curve_get(session));
}
if (ret < 0)
{
gnutls_assert ();
return ret;
}
data_size = ret;
/* Generate the signature. */
ddata.data = data->data;
ddata.size = data->length;
if (apr_cert_list_length > 0)
{
if ((ret =
_gnutls_handshake_sign_data (session, &apr_cert_list[0],
apr_pkey, &ddata, &signature,
&sign_algo)) < 0)
{
gnutls_assert ();
goto cleanup;
}
}
else
{
gnutls_assert ();
ret = data_size; /* do not put a signature - ILLEGAL! */
goto cleanup;
}
if (_gnutls_version_has_selectable_sighash (ver))
{
const sign_algorithm_st *aid;
uint8_t p[2];
if (sign_algo == GNUTLS_SIGN_UNKNOWN)
{
ret = GNUTLS_E_UNKNOWN_ALGORITHM;
goto cleanup;
}
aid = _gnutls_sign_to_tls_aid (sign_algo);
if (aid == NULL)
{
gnutls_assert();
ret = GNUTLS_E_UNKNOWN_ALGORITHM;
goto cleanup;
}
p[0] = aid->hash_algorithm;
p[1] = aid->sign_algorithm;
ret = _gnutls_buffer_append_data(data, p, 2);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
}
ret = _gnutls_buffer_append_data_prefix(data, 16, signature.data, signature.size);
if (ret < 0)
{
gnutls_assert();
}
ret = data->length;
cleanup:
_gnutls_free_datum (&signature);
return ret;
}
|
↓
|
_gnutls_proc_x509_server_certificate
|
14
|
65
|
139
|
auth/cert.c
|
static int
_gnutls_proc_x509_server_certificate (gnutls_session_t session,
opaque * data, size_t data_size)
{
int size, len, ret;
opaque *p = data;
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
ssize_t dsize = data_size;
int i;
gnutls_pcert_st *peer_certificate_list;
size_t peer_certificate_list_size = 0, j, x;
gnutls_datum_t tmp;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if ((ret =
_gnutls_auth_info_set (session, GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
if (data == NULL || data_size == 0)
{
gnutls_assert ();
/* no certificate was sent */
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
DECR_LEN (dsize, 3);
size = _gnutls_read_uint24 (p);
p += 3;
/* some implementations send 0B 00 00 06 00 00 03 00 00 00
* instead of just 0B 00 00 03 00 00 00 as an empty certificate message.
*/
if (size == 0 || size == 3)
{
gnutls_assert ();
/* no certificate was sent */
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
i = dsize;
while (i > 0)
{
DECR_LEN (dsize, 3);
len = _gnutls_read_uint24 (p);
p += 3;
DECR_LEN (dsize, len);
peer_certificate_list_size++;
p += len;
i -= len + 3;
}
if (peer_certificate_list_size == 0)
{
gnutls_assert ();
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
/* Ok we now allocate the memory to hold the
* certificate list
*/
peer_certificate_list =
gnutls_calloc (1,
sizeof (gnutls_pcert_st) * (peer_certificate_list_size));
if (peer_certificate_list == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
p = data + 3;
/* Now we start parsing the list (again).
* We don't use DECR_LEN since the list has
* been parsed before.
*/
for (j = 0; j < peer_certificate_list_size; j++)
{
len = _gnutls_read_uint24 (p);
p += 3;
tmp.size = len;
tmp.data = p;
ret =
gnutls_pcert_import_x509_raw (&peer_certificate_list
[j], &tmp, GNUTLS_X509_FMT_DER, 0);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
p += len;
}
if ((ret =
_gnutls_copy_certificate_auth_info (info,
peer_certificate_list,
peer_certificate_list_size, 0,
NULL)) < 0)
{
gnutls_assert ();
goto cleanup;
}
if ((ret =
_gnutls_check_key_usage (&peer_certificate_list[0],
gnutls_kx_get (session))) < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = 0;
cleanup:
CLEAR_CERTS;
gnutls_free (peer_certificate_list);
return ret;
}
|
↓
|
get_extension
|
14
|
60
|
123
|
x509/extensions.c
|
int
get_extension (ASN1_TYPE asn, const char *root,
const char *extension_id, int indx,
gnutls_datum_t * ret, unsigned int *_critical)
{
int k, result, len;
char name[ASN1_MAX_NAME_SIZE], name2[ASN1_MAX_NAME_SIZE];
char str[1024];
char str_critical[10];
int critical = 0;
char extnID[128];
gnutls_datum_t value;
int indx_counter = 0;
ret->data = NULL;
ret->size = 0;
k = 0;
do
{
k++;
snprintf (name, sizeof (name), "%s.?%u", root, k);
len = sizeof (str) - 1;
result = asn1_read_value (asn, name, str, &len);
/* move to next
*/
if (result == ASN1_ELEMENT_NOT_FOUND)
{
break;
}
do
{
_gnutls_str_cpy (name2, sizeof (name2), name);
_gnutls_str_cat (name2, sizeof (name2), ".extnID");
len = sizeof (extnID) - 1;
result = asn1_read_value (asn, name2, extnID, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
gnutls_assert ();
break;
}
else if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
/* Handle Extension
*/
if (strcmp (extnID, extension_id) == 0 && indx == indx_counter++)
{
/* extension was found
*/
/* read the critical status.
*/
_gnutls_str_cpy (name2, sizeof (name2), name);
_gnutls_str_cat (name2, sizeof (name2), ".critical");
len = sizeof (str_critical);
result = asn1_read_value (asn, name2, str_critical, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
gnutls_assert ();
break;
}
else if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
if (str_critical[0] == 'T')
critical = 1;
else
critical = 0;
/* read the value.
*/
_gnutls_str_cpy (name2, sizeof (name2), name);
_gnutls_str_cat (name2, sizeof (name2), ".extnValue");
result = _gnutls_x509_read_value (asn, name2, &value, 0);
if (result < 0)
{
gnutls_assert ();
return result;
}
ret->data = value.data;
ret->size = value.size;
if (_critical)
*_critical = critical;
return 0;
}
}
while (0);
}
while (1);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
else
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
}
|
↓
|
gnutls_x509_privkey_export_rsa_raw2
|
14
|
59
|
118
|
x509/privkey.c
|
int
gnutls_x509_privkey_export_rsa_raw2 (gnutls_x509_privkey_t key,
gnutls_datum_t * m, gnutls_datum_t * e,
gnutls_datum_t * d, gnutls_datum_t * p,
gnutls_datum_t * q, gnutls_datum_t * u,
gnutls_datum_t * e1, gnutls_datum_t * e2)
{
int ret;
gnutls_pk_params_st pk_params;
gnutls_pk_params_init(&pk_params);
if (key == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
m->data = e->data = d->data = p->data = q->data = u->data = NULL;
m->size = e->size = d->size = p->size = q->size = u->size = 0;
ret = _gnutls_pk_params_copy (&pk_params, &key->params);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_pk_fixup (GNUTLS_PK_RSA, GNUTLS_EXPORT, &pk_params);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
ret = _gnutls_mpi_dprint_lz (pk_params.params[0], m);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
/* E */
ret = _gnutls_mpi_dprint_lz (pk_params.params[1], e);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
/* D */
ret = _gnutls_mpi_dprint_lz (pk_params.params[2], d);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
/* P */
ret = _gnutls_mpi_dprint_lz (pk_params.params[3], p);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
/* Q */
ret = _gnutls_mpi_dprint_lz (pk_params.params[4], q);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
/* U */
ret = _gnutls_mpi_dprint_lz (key->params.params[5], u);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
/* E1 */
if (e1)
{
ret = _gnutls_mpi_dprint_lz (key->params.params[6], e1);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
}
/* E2 */
if (e2)
{
ret = _gnutls_mpi_dprint_lz (key->params.params[7], e2);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
}
gnutls_pk_params_release (&pk_params);
return 0;
error:
_gnutls_free_datum (m);
_gnutls_free_datum (d);
_gnutls_free_datum (e);
_gnutls_free_datum (p);
_gnutls_free_datum (q);
gnutls_pk_params_release (&pk_params);
return ret;
}
|
↓
|
parse_attribute
|
14
|
58
|
124
|
x509/crq.c
|
static int
parse_attribute (ASN1_TYPE asn1_struct,
const char *attr_name, const char *given_oid, int indx,
int raw, char *buf, size_t * sizeof_buf)
{
int k1, result;
char tmpbuffer1[ASN1_MAX_NAME_SIZE];
char tmpbuffer3[ASN1_MAX_NAME_SIZE];
char value[200];
char oid[MAX_OID_SIZE];
int len, printable;
k1 = 0;
do
{
k1++;
/* create a string like "attribute.?1"
*/
if (attr_name[0] != 0)
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", attr_name, k1);
else
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
gnutls_assert ();
break;
}
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Move to the attibute type and values
*/
/* Read the OID
*/
_gnutls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer1);
_gnutls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
len = sizeof (oid) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
break;
else if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (strcmp (oid, given_oid) == 0)
{ /* Found the OID */
/* Read the Value
*/
snprintf (tmpbuffer3, sizeof (tmpbuffer3), "%s.values.?%u",
tmpbuffer1, indx + 1);
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer3, value, &len);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (raw == 0)
{
printable = _gnutls_x509_oid_data_printable (oid);
if (printable == 1)
{
if ((result =
_gnutls_x509_oid_data2string
(oid, value, len, buf, sizeof_buf)) < 0)
{
gnutls_assert ();
goto cleanup;
}
return 0;
}
else
{
gnutls_assert ();
return GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE;
}
}
else
{ /* raw!=0 */
if (*sizeof_buf >= (size_t) len && buf != NULL)
{
*sizeof_buf = len;
memcpy (buf, value, len);
return 0;
}
else
{
*sizeof_buf = len;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
}
}
}
while (1);
gnutls_assert ();
result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
cleanup:
return result;
}
|
↓
|
gnutls_x509_crt_get_crl_dist_points
|
14
|
50
|
102
|
x509/x509.c
|
int
gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
unsigned int seq, void *ret,
size_t * ret_size,
unsigned int *reason_flags,
unsigned int *critical)
{
int result;
gnutls_datum_t dist_points = { NULL, 0 };
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
char name[ASN1_MAX_NAME_SIZE];
int len;
gnutls_x509_subject_alt_name_t type;
uint8_t reasons[2];
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (*ret_size > 0 && ret)
memset (ret, 0, *ret_size);
else
*ret_size = 0;
if (reason_flags)
*reason_flags = 0;
result =
_gnutls_x509_crt_get_extension (cert, "2.5.29.31", 0, &dist_points,
critical);
if (result < 0)
{
return result;
}
if (dist_points.size == 0 || dist_points.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.CRLDistributionPoints", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_free_datum (&dist_points);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, dist_points.data, dist_points.size, NULL);
_gnutls_free_datum (&dist_points);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
/* Return the different names from the first CRLDistr. point.
* The whole thing is a mess.
*/
_gnutls_str_cpy (name, sizeof (name), "?1.distributionPoint.fullName");
result = _gnutls_parse_general_name (c2, name, seq, ret, ret_size, NULL, 0);
if (result < 0)
{
asn1_delete_structure (&c2);
return result;
}
type = result;
/* Read the CRL reasons.
*/
if (reason_flags)
{
_gnutls_str_cpy (name, sizeof (name), "?1.reasons");
reasons[0] = reasons[1] = 0;
len = sizeof (reasons);
result = asn1_read_value (c2, name, reasons, &len);
if (result != ASN1_VALUE_NOT_FOUND && result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
*reason_flags = reasons[0] | (reasons[1] << 8);
}
asn1_delete_structure (&c2);
return type;
}
|
↓
|
_gnutls_x509_crt_check_revocation
|
14
|
49
|
97
|
x509/x509.c
|
int
_gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
const gnutls_x509_crl_t * crl_list,
int crl_list_length,
gnutls_verify_output_function func)
{
opaque serial[128];
opaque cert_serial[128];
size_t serial_size, cert_serial_size;
int ncerts, ret, i, j;
gnutls_datum_t dn1, dn2;
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
for (j = 0; j < crl_list_length; j++)
{ /* do for all the crls */
/* Step 1. check if issuer's DN match
*/
ret = gnutls_x509_crl_get_raw_issuer_dn (crl_list[j], &dn1);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = gnutls_x509_crt_get_raw_issuer_dn (cert, &dn2);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_x509_compare_raw_dn (&dn1, &dn2);
_gnutls_free_datum (&dn1);
_gnutls_free_datum (&dn2);
if (ret == 0)
{
/* issuers do not match so don't even
* bother checking.
*/
continue;
}
/* Step 2. Read the certificate's serial number
*/
cert_serial_size = sizeof (cert_serial);
ret = gnutls_x509_crt_get_serial (cert, cert_serial, &cert_serial_size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* Step 3. cycle through the CRL serials and compare with
* certificate serial we have.
*/
ncerts = gnutls_x509_crl_get_crt_count (crl_list[j]);
if (ncerts < 0)
{
gnutls_assert ();
return ncerts;
}
for (i = 0; i < ncerts; i++)
{
serial_size = sizeof (serial);
ret =
gnutls_x509_crl_get_crt_serial (crl_list[j], i, serial,
&serial_size, NULL);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (serial_size == cert_serial_size)
{
if (memcmp (serial, cert_serial, serial_size) == 0)
{
/* serials match */
if (func) func(cert, NULL, crl_list[j], GNUTLS_CERT_REVOKED|GNUTLS_CERT_INVALID);
return 1; /* revoked! */
}
}
}
if (func) func(cert, NULL, crl_list[j], 0);
}
return 0; /* not revoked. */
}
|
↓
|
_gnutls_gen_openpgp_certificate
|
14
|
47
|
90
|
auth/cert.c
|
static int
_gnutls_gen_openpgp_certificate (gnutls_session_t session,
gnutls_buffer_st * data)
{
int ret;
gnutls_pcert_st *apr_cert_list;
gnutls_privkey_t apr_pkey;
int apr_cert_list_length;
uint8_t type;
uint8_t fpr[20];
size_t fpr_size;
unsigned int use_subkey = 0;
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
return ret;
}
ret = 3 + 1 + 3;
if (apr_cert_list_length > 0)
{
fpr_size = sizeof (fpr);
ret =
gnutls_pubkey_get_openpgp_key_id (apr_cert_list[0].pubkey, 0, fpr,
&fpr_size, &use_subkey);
if (ret < 0)
return gnutls_assert_val (ret);
if (use_subkey != 0)
ret += 1 + fpr_size; /* for the keyid */
ret += apr_cert_list[0].cert.size;
}
ret = _gnutls_buffer_append_prefix (data, 24, ret - 3);
if (ret < 0)
return gnutls_assert_val (ret);
if (apr_cert_list_length > 0)
{
if (use_subkey != 0)
{
type = PGP_KEY_SUBKEY;
ret = _gnutls_buffer_append_data (data, &type, 1);
if (ret < 0)
return gnutls_assert_val (ret);
ret = _gnutls_buffer_append_data_prefix (data, 8, fpr, fpr_size);
if (ret < 0)
return gnutls_assert_val (ret);
}
else
{
type = PGP_KEY;
ret = _gnutls_buffer_append_data (data, &type, 1);
if (ret < 0)
return gnutls_assert_val (ret);
}
ret =
_gnutls_buffer_append_data_prefix (data, 24,
apr_cert_list[0].cert.data,
apr_cert_list[0].cert.size);
if (ret < 0)
return gnutls_assert_val (ret);
}
else /* empty - no certificate */
{
type = PGP_KEY;
ret = _gnutls_buffer_append_data (data, &type, 1);
if (ret < 0)
return gnutls_assert_val (ret);
ret = _gnutls_buffer_append_prefix (data, 24, 0);
if (ret < 0)
return gnutls_assert_val (ret);
}
return data->length;
}
|
↓
|
print_cert
|
14
|
44
|
80
|
openpgp/output.c
|
static void
print_cert (gnutls_buffer_st * str, gnutls_openpgp_crt_t cert)
{
int i, subkeys;
int err;
print_key_revoked (str, cert, -1);
/* Version. */
{
int version = gnutls_openpgp_crt_get_version (cert);
if (version < 0)
addf (str, "error: get_version: %s\n", gnutls_strerror (version));
else
addf (str, _("\tVersion: %d\n"), version);
}
/* ID. */
print_key_id (str, cert, -1);
print_key_fingerprint (str, cert);
/* Names. */
i = 0;
do
{
char *dn;
size_t dn_size = 0;
err = gnutls_openpgp_crt_get_name (cert, i, NULL, &dn_size);
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER
&& err != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
&& err != GNUTLS_E_OPENPGP_UID_REVOKED)
addf (str, "error: get_name: %s\n", gnutls_strerror (err));
else
{
dn = gnutls_malloc (dn_size);
if (!dn)
addf (str, "error: malloc (%d): %s\n", (int) dn_size,
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
else
{
err = gnutls_openpgp_crt_get_name (cert, i, dn, &dn_size);
if (err < 0 && err != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE &&
err != GNUTLS_E_OPENPGP_UID_REVOKED)
addf (str, "error: get_name: %s\n", gnutls_strerror (err));
else if (err >= 0)
addf (str, _("\tName[%d]: %s\n"), i, dn);
else if (err == GNUTLS_E_OPENPGP_UID_REVOKED)
addf (str, _("\tRevoked Name[%d]: %s\n"), i, dn);
gnutls_free (dn);
}
}
i++;
}
while (err >= 0);
print_key_times (str, cert, -1);
print_key_info (str, cert, -1);
print_key_usage (str, cert, -1);
subkeys = gnutls_openpgp_crt_get_subkey_count (cert);
if (subkeys < 0)
return;
for (i = 0; i < subkeys; i++)
{
addf (str, _("\n\tSubkey[%d]:\n"), i);
print_key_revoked (str, cert, i);
print_key_id (str, cert, i);
print_key_times (str, cert, i);
print_key_info (str, cert, i);
print_key_usage (str, cert, i);
}
}
|
↓
|
_select_client_cert
|
14
|
43
|
107
|
auth/cert.c
|
static int
_select_client_cert (gnutls_session_t session,
opaque * _data, size_t _data_size,
gnutls_pk_algorithm_t * pk_algos, int pk_algos_length)
{
int result;
int indx = -1;
gnutls_certificate_credentials_t cred;
opaque *data = _data;
ssize_t data_size = _data_size;
int issuers_dn_length;
gnutls_datum_t *issuers_dn = NULL;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if (cred->client_get_cert_callback != NULL
|| cred->get_cert_callback != NULL || cred->get_cert_callback2 != NULL)
{
/* use a callback to get certificate
*/
if (session->security_parameters.cert_type != GNUTLS_CRT_X509)
issuers_dn_length = 0;
else
{
issuers_dn_length = get_issuers_num (session, data, data_size);
if (issuers_dn_length < 0)
{
gnutls_assert ();
return issuers_dn_length;
}
if (issuers_dn_length > 0)
{
issuers_dn =
gnutls_malloc (sizeof (gnutls_datum_t) * issuers_dn_length);
if (issuers_dn == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result =
get_issuers (session, issuers_dn, issuers_dn_length,
data, data_size);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
}
}
result =
call_get_cert_callback (session, issuers_dn, issuers_dn_length,
pk_algos, pk_algos_length);
goto cleanup;
}
else
{
/* If we have no callbacks, try to guess.
*/
result = 0;
if (session->security_parameters.cert_type == GNUTLS_CRT_X509)
result =
_find_x509_cert (cred, _data, _data_size,
pk_algos, pk_algos_length, &indx);
#ifdef ENABLE_OPENPGP
if (session->security_parameters.cert_type == GNUTLS_CRT_OPENPGP)
result = _find_openpgp_cert (cred, pk_algos, pk_algos_length, &indx);
#endif
if (result < 0)
{
gnutls_assert ();
return result;
}
if (indx >= 0)
{
_gnutls_selected_certs_set (session,
&cred->certs[indx].cert_list[0],
cred->certs[indx].cert_list_length,
cred->pkey[indx], 0);
}
else
{
_gnutls_selected_certs_set (session, NULL, 0, NULL, 0);
}
result = 0;
}
cleanup:
gnutls_free (issuers_dn);
return result;
}
|
↓
|
gnutls_certificate_set_x509_simple_pkcs12_mem
|
14
|
43
|
77
|
gnutls_x509.c
|
int
gnutls_certificate_set_x509_simple_pkcs12_mem
(gnutls_certificate_credentials_t res, const gnutls_datum_t * p12blob,
gnutls_x509_crt_fmt_t type, const char *password)
{
gnutls_pkcs12_t p12;
gnutls_x509_privkey_t key = NULL;
gnutls_x509_crt_t cert = NULL;
gnutls_x509_crl_t crl = NULL;
int ret;
ret = gnutls_pkcs12_init (&p12);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = gnutls_pkcs12_import (p12, p12blob, type, 0);
if (ret < 0)
{
gnutls_assert ();
gnutls_pkcs12_deinit (p12);
return ret;
}
if (password)
{
ret = gnutls_pkcs12_verify_mac (p12, password);
if (ret < 0)
{
gnutls_assert ();
gnutls_pkcs12_deinit (p12);
return ret;
}
}
ret = parse_pkcs12 (res, p12, password, &key, &cert, &crl);
gnutls_pkcs12_deinit (p12);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (key && cert)
{
ret = gnutls_certificate_set_x509_key (res, &cert, 1, key);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
}
if (crl)
{
ret = gnutls_certificate_set_x509_crl (res, &crl, 1);
if (ret < 0)
{
gnutls_assert ();
goto done;
}
}
ret = 0;
done:
if (cert)
gnutls_x509_crt_deinit (cert);
if (key)
gnutls_x509_privkey_deinit (key);
if (crl)
gnutls_x509_crl_deinit (crl);
return ret;
}
|
↓
|
gnutls_openpgp_keyring_import
|
14
|
43
|
83
|
openpgp/extras.c
|
int
gnutls_openpgp_keyring_import (gnutls_openpgp_keyring_t keyring,
const gnutls_datum_t * data,
gnutls_openpgp_crt_fmt_t format)
{
cdk_error_t err;
cdk_stream_t input = NULL;
size_t raw_len = 0;
opaque *raw_data = NULL;
if (data->data == NULL || data->size == 0)
{
gnutls_assert ();
return GNUTLS_E_OPENPGP_GETKEY_FAILED;
}
_gnutls_debug_log ("PGP: keyring import format '%s'\n",
format == GNUTLS_OPENPGP_FMT_RAW ? "raw" : "base64");
/* Create a new stream from the given data, decode it, and import
* the raw database. This to avoid using opencdk streams which are
* not thread safe.
*/
if (format == GNUTLS_OPENPGP_FMT_BASE64)
{
size_t written = 0;
err = cdk_stream_tmp_from_mem (data->data, data->size, &input);
if (err == 0)
err = cdk_stream_set_armor_flag (input, 0);
if (err)
{
gnutls_assert ();
err = _gnutls_map_cdk_rc (err);
goto error;
}
raw_len = cdk_stream_get_length (input);
if (raw_len == 0)
{
gnutls_assert ();
err = GNUTLS_E_BASE64_DECODING_ERROR;
goto error;
}
raw_data = gnutls_malloc (raw_len);
if (raw_data == NULL)
{
gnutls_assert ();
err = GNUTLS_E_MEMORY_ERROR;
goto error;
}
do
{
err =
cdk_stream_read (input, raw_data + written, raw_len - written);
if (err > 0)
written += err;
}
while (written < raw_len && err != EOF && err > 0);
raw_len = written;
}
else
{ /* RAW */
raw_len = data->size;
raw_data = data->data;
}
err = cdk_keydb_new_from_mem (&keyring->db, 0, 0, raw_data, raw_len);
if (err)
gnutls_assert ();
return _gnutls_map_cdk_rc (err);
error:
gnutls_free (raw_data);
cdk_stream_close (input);
return err;
}
|
|
_gnutls_x509_ext_extract_proxyCertInfo
|
14
|
41
|
77
|
x509/extensions.c
|
|
↓
|
_gnutls_srp_send_params
|
14
|
40
|
84
|
ext/srp.c
|
static int
_gnutls_srp_send_params (gnutls_session_t session,
gnutls_buffer_st * extdata)
{
unsigned len;
int ret;
extension_priv_data_t epriv;
srp_ext_st *priv;
char *username = NULL, *password = NULL;
if (_gnutls_kx_priority (session, GNUTLS_KX_SRP) < 0 &&
_gnutls_kx_priority (session, GNUTLS_KX_SRP_DSS) < 0 &&
_gnutls_kx_priority (session, GNUTLS_KX_SRP_RSA) < 0)
{
/* algorithm was not allowed in this session
*/
return 0;
}
/* this function sends the client extension data (username) */
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
gnutls_srp_client_credentials_t cred = (gnutls_srp_client_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_SRP, NULL);
if (cred == NULL)
return 0;
if (cred->username != NULL)
{ /* send username */
len = MIN (strlen (cred->username), 255);
ret = _gnutls_buffer_append_data_prefix(extdata, 8, cred->username, len);
if (ret < 0)
return gnutls_assert_val(ret);
return len + 1;
}
else if (cred->get_function != NULL)
{
/* Try the callback
*/
if (cred->get_function (session, &username, &password) < 0
|| username == NULL || password == NULL)
{
gnutls_assert ();
return GNUTLS_E_ILLEGAL_SRP_USERNAME;
}
len = MIN (strlen (username), 255);
priv = gnutls_malloc (sizeof (*priv));
if (priv == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
priv->username = username;
priv->password = password;
epriv.ptr = priv;
_gnutls_ext_set_session_data (session, GNUTLS_EXTENSION_SRP, epriv);
ret = _gnutls_buffer_append_data_prefix(extdata, 8, username, len);
if (ret < 0)
{
ret = gnutls_assert_val(ret);
goto cleanup;
}
return len + 1;
}
}
return 0;
cleanup:
gnutls_free (username);
gnutls_free (password);
return ret;
}
|
↓
|
cdk_stream_close
|
14
|
39
|
68
|
opencdk/stream.c
|
cdk_error_t
cdk_stream_close (cdk_stream_t s)
{
struct stream_filter_s *f, *f2;
cdk_error_t rc;
if (!s)
{
gnutls_assert ();
return CDK_Inv_Value;
}
_gnutls_read_log ("close stream ref=%d `%s'\n",
s->fp_ref, s->fname ? s->fname : "[temp]");
/* In the user callback mode, we call the release cb if possible
and just free the stream. */
if (s->cbs_hd)
{
if (s->cbs.release)
rc = s->cbs.release (s->cbs_hd);
else
rc = 0;
cdk_free (s);
gnutls_assert ();
return rc;
}
rc = 0;
if (!s->flags.filtrated && !s->error)
rc = cdk_stream_flush (s);
if (!s->fp_ref && (s->fname || s->flags.temp))
{
int err;
_gnutls_read_log ("close stream fd=%d\n", fileno (s->fp));
err = fclose (s->fp);
s->fp = NULL;
if (err)
rc = CDK_File_Error;
}
/* Iterate over the filter list and use the cleanup flag to
free the allocated internal structures. */
f = s->filters;
while (f)
{
f2 = f->next;
if (f->fnct)
f->fnct (f->opaque, STREAMCTL_FREE, NULL, NULL);
cdk_free (f);
f = f2;
}
if (s->fname)
{
cdk_free (s->fname);
s->fname = NULL;
}
cdk_free (s->cache.buf);
s->cache.alloced = 0;
cdk_free (s);
gnutls_assert ();
return rc;
}
|
↓
|
gnutls_ocsp_resp_import
|
14
|
39
|
88
|
x509/ocsp.c
|
int
gnutls_ocsp_resp_import (gnutls_ocsp_resp_t resp,
const gnutls_datum_t * data)
{
int ret = 0;
if (resp == NULL || data == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (resp->resp)
{
/* Any earlier asn1_der_decoding will modify the ASN.1
structure, so we need to replace it with a fresh
structure. */
asn1_delete_structure (&resp->resp);
ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.OCSPResponse", &resp->resp);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (ret);
}
}
ret = asn1_der_decoding (&resp->resp, data->data, data->size, NULL);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (ret);
}
if (gnutls_ocsp_resp_get_status (resp) != GNUTLS_OCSP_RESP_SUCCESSFUL)
return GNUTLS_E_SUCCESS;
ret = _gnutls_x509_read_value (resp->resp, "responseBytes.responseType",
&resp->response_type_oid, 0);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
#define OCSP_BASIC "1.3.6.1.5.5.7.48.1.1"
if (resp->response_type_oid.size == sizeof (OCSP_BASIC)
&& memcmp (resp->response_type_oid.data, OCSP_BASIC,
resp->response_type_oid.size) == 0)
{
gnutls_datum_t d;
if (resp->basicresp)
{
asn1_delete_structure (&resp->basicresp);
ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.BasicOCSPResponse", &resp->basicresp);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (ret);
}
}
ret = _gnutls_x509_read_value (resp->resp, "responseBytes.response",
&d, 0);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = asn1_der_decoding (&resp->basicresp, d.data, d.size, NULL);
gnutls_free (d.data);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (ret);
}
}
else
resp->basicresp = NULL;
return GNUTLS_E_SUCCESS;
}
|
↓
|
check_server_params
|
14
|
38
|
108
|
gnutls_handshake.c
|
inline static int
check_server_params (gnutls_session_t session,
gnutls_kx_algorithm_t kx,
gnutls_kx_algorithm_t * alg, int alg_size)
{
int cred_type;
gnutls_dh_params_t dh_params = NULL;
gnutls_rsa_params_t rsa_params = NULL;
int j;
cred_type = _gnutls_map_kx_get_cred (kx, 1);
/* Read the Diffie-Hellman parameters, if any.
*/
if (cred_type == GNUTLS_CRD_CERTIFICATE)
{
int delete;
gnutls_certificate_credentials_t x509_cred =
(gnutls_certificate_credentials_t) _gnutls_get_cred (session->key,
cred_type, NULL);
if (x509_cred != NULL)
{
dh_params =
_gnutls_get_dh_params (x509_cred->dh_params,
x509_cred->params_func, session);
rsa_params =
_gnutls_certificate_get_rsa_params (x509_cred->rsa_params,
x509_cred->params_func,
session);
}
/* Check also if the certificate supports the
* KX method.
*/
delete = 1;
for (j = 0; j < alg_size; j++)
{
if (alg[j] == kx)
{
delete = 0;
break;
}
}
if (delete == 1)
return 1;
#ifdef ENABLE_ANON
}
else if (cred_type == GNUTLS_CRD_ANON)
{
gnutls_anon_server_credentials_t anon_cred =
(gnutls_anon_server_credentials_t) _gnutls_get_cred (session->key,
cred_type, NULL);
if (anon_cred != NULL)
{
dh_params =
_gnutls_get_dh_params (anon_cred->dh_params,
anon_cred->params_func, session);
}
#endif
#ifdef ENABLE_PSK
}
else if (cred_type == GNUTLS_CRD_PSK)
{
gnutls_psk_server_credentials_t psk_cred =
(gnutls_psk_server_credentials_t) _gnutls_get_cred (session->key,
cred_type, NULL);
if (psk_cred != NULL)
{
dh_params =
_gnutls_get_dh_params (psk_cred->dh_params, psk_cred->params_func,
session);
}
#endif
}
else
return 0; /* no need for params */
/* If the key exchange method needs RSA or DH params,
* but they are not set then remove it.
*/
if (_gnutls_kx_needs_rsa_params (kx) != 0)
{
/* needs rsa params. */
if (_gnutls_rsa_params_to_mpi (rsa_params) == NULL)
{
gnutls_assert ();
return 1;
}
}
if (_gnutls_kx_needs_dh_params (kx) != 0)
{
/* needs DH params. */
if (_gnutls_dh_params_to_mpi (dh_params) == NULL)
{
gnutls_assert ();
return 1;
}
}
return 0;
}
|
↓
|
_gnutls_gen_extensions
|
14
|
38
|
67
|
gnutls_extensions.c
|
int
_gnutls_gen_extensions (gnutls_session_t session, gnutls_buffer_st * extdata,
gnutls_ext_parse_type_t parse_type)
{
int size;
int pos, size_pos, ret;
size_t i, init_size = extdata->length;
pos = extdata->length; /* we will store length later on */
_gnutls_buffer_append_prefix( extdata, 16, 0);
for (i = 0; i < extfunc_size; i++)
{
extension_entry_st *p = &extfunc[i];
if (p->send_func == NULL)
continue;
if (parse_type != GNUTLS_EXT_ANY && p->parse_type != parse_type)
continue;
ret = _gnutls_buffer_append_prefix( extdata, 16, p->type);
if (ret < 0)
return gnutls_assert_val(ret);
size_pos = extdata->length;
ret = _gnutls_buffer_append_prefix (extdata, 16, 0);
if (ret < 0)
return gnutls_assert_val(ret);
size = p->send_func (session, extdata);
/* returning GNUTLS_E_INT_RET_0 means to send an empty
* extension of this type.
*/
if (size > 0 || size == GNUTLS_E_INT_RET_0)
{
if (size == GNUTLS_E_INT_RET_0)
size = 0;
/* write the real size */
_gnutls_write_uint16(size, &extdata->data[size_pos]);
/* add this extension to the extension list
*/
_gnutls_extension_list_add (session, p->type);
_gnutls_handshake_log ("EXT[%p]: Sending extension %s (%d bytes)\n",
session, p->name, size);
}
else if (size < 0)
{
gnutls_assert ();
return size;
}
else if (size == 0)
extdata->length -= 4; /* reset type and size */
}
/* remove any initial data, and the size of the header */
size = extdata->length - init_size - 2;
if ( size > 0)
_gnutls_write_uint16(size, &extdata->data[pos]);
else if (size == 0) extdata->length -= 2; /* the length bytes */
return size;
}
|
↓
|
merge_handshake_packet
|
14
|
35
|
70
|
gnutls_buffers.c
|
static int merge_handshake_packet(gnutls_session_t session, handshake_buffer_st* hsk)
{
int exists = 0, i, pos = 0;
int ret;
for (i=0;iinternals.handshake_recv_buffer_size;i++)
{
if (session->internals.handshake_recv_buffer[i].htype == hsk->htype)
{
exists = 1;
pos = i;
break;
}
}
if (exists == 0)
pos = session->internals.handshake_recv_buffer_size;
if (pos > MAX_HANDSHAKE_MSGS)
return gnutls_assert_val(GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS);
if (exists == 0)
{
if (hsk->length > 0 && hsk->end_offset > 0 && hsk->end_offset-hsk->start_offset+1 != hsk->length)
{
ret = _gnutls_buffer_resize(&hsk->data, hsk->length);
if (ret < 0)
return gnutls_assert_val(ret);
hsk->data.length = hsk->length;
memmove(&hsk->data.data[hsk->start_offset], hsk->data.data, hsk->end_offset-hsk->start_offset+1);
}
session->internals.handshake_recv_buffer_size++;
/* rewrite headers to make them look as each packet came as a single fragment */
_gnutls_write_uint24(hsk->length, &hsk->header[1]);
_gnutls_write_uint24(0, &hsk->header[6]);
_gnutls_write_uint24(hsk->length, &hsk->header[9]);
_gnutls_handshake_buffer_move(&session->internals.handshake_recv_buffer[pos], hsk);
}
else
{
if (hsk->start_offset < session->internals.handshake_recv_buffer[pos].start_offset &&
hsk->end_offset >= session->internals.handshake_recv_buffer[pos].start_offset)
{
memcpy(&session->internals.handshake_recv_buffer[pos].data.data[hsk->start_offset],
hsk->data.data, hsk->data.length);
session->internals.handshake_recv_buffer[pos].start_offset = hsk->start_offset;
session->internals.handshake_recv_buffer[pos].end_offset =
MIN(hsk->end_offset, session->internals.handshake_recv_buffer[pos].end_offset);
}
else if (hsk->end_offset > session->internals.handshake_recv_buffer[pos].end_offset &&
hsk->start_offset <= session->internals.handshake_recv_buffer[pos].end_offset+1)
{
memcpy(&session->internals.handshake_recv_buffer[pos].data.data[hsk->start_offset],
hsk->data.data, hsk->data.length);
session->internals.handshake_recv_buffer[pos].end_offset = hsk->end_offset;
session->internals.handshake_recv_buffer[pos].start_offset =
MIN(hsk->start_offset, session->internals.handshake_recv_buffer[pos].start_offset);
}
_gnutls_handshake_buffer_clear(hsk);
}
return 0;
}
|
↓
|
cdk_listkey_start
|
14
|
35
|
52
|
opencdk/keydb.c
|
cdk_error_t
cdk_listkey_start (cdk_listkey_t * r_ctx, cdk_keydb_hd_t db,
const char *patt, cdk_strlist_t fpatt)
{
cdk_listkey_t ctx;
cdk_stream_t inp;
cdk_error_t rc;
if (!r_ctx || !db)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if ((patt && fpatt) || (!patt && !fpatt))
{
gnutls_assert ();
return CDK_Inv_Mode;
}
rc = _cdk_keydb_open (db, &inp);
if (rc)
{
gnutls_assert ();
return rc;
}
ctx = cdk_calloc (1, sizeof *ctx);
if (!ctx)
{
gnutls_assert ();
return CDK_Out_Of_Core;
}
ctx->db = db;
ctx->inp = inp;
if (patt)
{
ctx->u.patt = cdk_strdup (patt);
if (!ctx->u.patt)
{
gnutls_assert ();
return CDK_Out_Of_Core;
}
}
else if (fpatt)
{
cdk_strlist_t l;
for (l = fpatt; l; l = l->next)
cdk_strlist_add (&ctx->u.fpatt, l->d);
}
ctx->type = patt ? 1 : 0;
ctx->init = 1;
*r_ctx = ctx;
return 0;
}
|
↓
|
cdk_kbnode_write_to_mem_alloc
|
14
|
29
|
52
|
opencdk/kbnode.c
|
cdk_error_t
cdk_kbnode_write_to_mem_alloc (cdk_kbnode_t node,
byte ** r_buf, size_t * r_buflen)
{
cdk_kbnode_t n;
cdk_stream_t s;
cdk_error_t rc;
size_t len;
if (!node || !r_buf || !r_buflen)
{
gnutls_assert ();
return CDK_Inv_Value;
}
*r_buf = NULL;
*r_buflen = 0;
rc = cdk_stream_tmp_new (&s);
if (rc)
{
gnutls_assert ();
return rc;
}
for (n = node; n; n = n->next)
{
/* Skip all packets which cannot occur in a key composition. */
if (n->pkt->pkttype != CDK_PKT_PUBLIC_KEY &&
n->pkt->pkttype != CDK_PKT_PUBLIC_SUBKEY &&
n->pkt->pkttype != CDK_PKT_SECRET_KEY &&
n->pkt->pkttype != CDK_PKT_SECRET_SUBKEY &&
n->pkt->pkttype != CDK_PKT_SIGNATURE &&
n->pkt->pkttype != CDK_PKT_USER_ID &&
n->pkt->pkttype != CDK_PKT_ATTRIBUTE)
continue;
rc = cdk_pkt_write (s, n->pkt);
if (rc)
{
cdk_stream_close (s);
gnutls_assert ();
return rc;
}
}
cdk_stream_seek (s, 0);
len = cdk_stream_get_length (s);
*r_buf = cdk_calloc (1, len);
*r_buflen = cdk_stream_read (s, *r_buf, len);
cdk_stream_close (s);
return 0;
}
|
↓
|
_gnutls_dsa_q_to_hash
|
14
|
28
|
41
|
gnutls_pubkey.c
|
gnutls_digest_algorithm_t
_gnutls_dsa_q_to_hash (gnutls_pk_algorithm_t algo, const gnutls_pk_params_st* params, int* hash_len)
{
int bits = 0;
if (algo == GNUTLS_PK_DSA)
bits = _gnutls_mpi_get_nbits (params->params[1]);
else if (algo == GNUTLS_PK_EC)
bits = gnutls_ecc_curve_get_size(params->flags)*8;
if (bits <= 160)
{
if (hash_len) *hash_len = 20;
return GNUTLS_DIG_SHA1;
}
else if (bits <= 192)
{
if (hash_len) *hash_len = 24;
return GNUTLS_DIG_SHA256;
}
else if (bits <= 224)
{
if (hash_len) *hash_len = 28;
return GNUTLS_DIG_SHA256;
}
else if (bits <= 256)
{
if (hash_len) *hash_len = 32;
return GNUTLS_DIG_SHA256;
}
else if (bits <= 384)
{
if (hash_len) *hash_len = 48;
return GNUTLS_DIG_SHA384;
}
else
{
if (hash_len) *hash_len = 64;
return GNUTLS_DIG_SHA512;
}
}
|
↓
|
_cdk_sig_check
|
14
|
23
|
38
|
opencdk/sig-check.c
|
cdk_error_t
_cdk_sig_check (cdk_pubkey_t pk, cdk_pkt_signature_t sig,
digest_hd_st * digest, int *r_expired)
{
cdk_error_t rc;
byte md[MAX_DIGEST_LEN];
time_t cur_time = (u32) gnutls_time (NULL);
if (!pk || !sig || !digest)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (sig->flags.checked)
return sig->flags.valid ? 0 : CDK_Bad_Sig;
if (!KEY_CAN_SIGN (pk->pubkey_algo))
return CDK_Inv_Algo;
if (pk->timestamp > sig->timestamp || pk->timestamp > cur_time)
return CDK_Time_Conflict;
if (r_expired && pk->expiredate
&& (pk->expiredate + pk->timestamp) > cur_time)
*r_expired = 1;
_cdk_hash_sig_data (sig, digest);
_gnutls_hash_output (digest, md);
if (md[0] != sig->digest_start[0] || md[1] != sig->digest_start[1])
{
gnutls_assert ();
return CDK_Chksum_Error;
}
rc = cdk_pk_verify (pk, sig, md);
cache_sig_result (sig, rc);
return rc;
}
|
↓
|
_gnutls_read_client_hello
|
14
|
101
|
203
|
gnutls_handshake.c
|
static int
_gnutls_read_client_hello (gnutls_session_t session, opaque * data,
int datalen)
{
uint8_t session_id_len;
int pos = 0, ret;
uint16_t suite_size, comp_size;
gnutls_protocol_t adv_version;
int neg_version;
int len = datalen;
opaque rnd[GNUTLS_RANDOM_SIZE], *suite_ptr, *comp_ptr, *session_id;
DECR_LEN (len, 2);
_gnutls_handshake_log ("HSK[%p]: Client's version: %d.%d\n", session,
data[pos], data[pos + 1]);
adv_version = _gnutls_version_get (data[pos], data[pos + 1]);
set_adv_version (session, data[pos], data[pos + 1]);
pos += 2;
neg_version = _gnutls_negotiate_version (session, adv_version);
if (neg_version < 0)
{
gnutls_assert ();
return neg_version;
}
/* Read client random value.
*/
DECR_LEN (len, GNUTLS_RANDOM_SIZE);
_gnutls_set_client_random (session, &data[pos]);
pos += GNUTLS_RANDOM_SIZE;
_gnutls_tls_create_random (rnd);
_gnutls_set_server_random (session, rnd);
session->security_parameters.timestamp = gnutls_time (NULL);
DECR_LEN (len, 1);
session_id_len = data[pos++];
/* RESUME SESSION
*/
if (session_id_len > TLS_MAX_SESSION_ID_SIZE)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
DECR_LEN (len, session_id_len);
session_id = &data[pos];
ret = _gnutls_server_restore_session (session, session_id, session_id_len);
pos += session_id_len;
if (session_id_len > 0) session->internals.resumption_requested = 1;
if (ret == 0)
{ /* resumed using default TLS resumption! */
/* Parse only the safe renegotiation extension
* We don't want to parse any other extensions since
* we don't want new extension values to overwrite the
* resumed ones.
*/
/* move forward to extensions */
DECR_LEN (len, 2);
suite_size = _gnutls_read_uint16 (&data[pos]);
pos += 2;
DECR_LEN (len, suite_size);
pos += suite_size;
DECR_LEN (len, 1);
comp_size = data[pos++]; /* z is the number of compression methods */
DECR_LEN (len, comp_size);
pos += comp_size;
ret = _gnutls_parse_extensions (session, GNUTLS_EXT_MANDATORY,
&data[pos], len);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
resume_copy_required_values (session);
session->internals.resumed = RESUME_TRUE;
return _gnutls_user_hello_func (session, adv_version);
}
else
{
_gnutls_generate_session_id (session->security_parameters.session_id,
&session->
security_parameters.session_id_size);
session->internals.resumed = RESUME_FALSE;
}
if (IS_DTLS(session))
{
int cookie_size;
DECR_LEN (len, 1);
cookie_size = data[pos++];
DECR_LEN (len, cookie_size);
pos+=cookie_size;
}
/* Remember ciphersuites for later
*/
DECR_LEN (len, 2);
suite_size = _gnutls_read_uint16 (&data[pos]);
pos += 2;
DECR_LEN (len, suite_size);
suite_ptr = &data[pos];
pos += suite_size;
/* Point to the compression methods
*/
DECR_LEN (len, 1);
comp_size = data[pos++]; /* z is the number of compression methods */
DECR_LEN (len, comp_size);
comp_ptr = &data[pos];
pos += comp_size;
/* Parse the extensions (if any)
*
* Unconditionally try to parse extensions; safe renegotiation uses them in
* sslv3 and higher, even though sslv3 doesn't officially support them.
*/
ret = _gnutls_parse_extensions (session, GNUTLS_EXT_APPLICATION,
&data[pos], len);
/* len is the rest of the parsed length */
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_user_hello_func (session, adv_version);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_parse_extensions (session, GNUTLS_EXT_MANDATORY,
&data[pos], len);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_parse_extensions (session, GNUTLS_EXT_TLS, &data[pos], len);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* resumed by session_ticket extension */
if (session->internals.resumed != RESUME_FALSE)
{
/* to indicate the client that the current session is resumed */
memcpy (session->internals.resumed_security_parameters.session_id,
session_id, session_id_len);
session->internals.resumed_security_parameters.session_id_size =
session_id_len;
session->internals.resumed_security_parameters.max_record_recv_size =
session->security_parameters.max_record_recv_size;
session->internals.resumed_security_parameters.max_record_send_size =
session->security_parameters.max_record_send_size;
resume_copy_required_values (session);
return _gnutls_user_hello_func (session, adv_version);
}
/* select an appropriate cipher suite
*/
ret = _gnutls_server_select_suite (session, suite_ptr, suite_size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* select appropriate compression method */
ret = _gnutls_server_select_comp_method (session, comp_ptr, comp_size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
|
↓
|
gnutls_pkcs11_copy_x509_crt
|
14
|
100
|
159
|
pkcs11_write.c
|
int
gnutls_pkcs11_copy_x509_crt (const char *token_url,
gnutls_x509_crt_t crt, const char *label,
unsigned int flags)
{
int ret;
struct ck_function_list *module;
ck_session_handle_t pks;
struct p11_kit_uri *info = NULL;
ck_rv_t rv;
size_t der_size, id_size;
opaque *der = NULL;
opaque id[20];
struct ck_attribute a[16];
ck_object_class_t class = CKO_CERTIFICATE;
ck_certificate_type_t type = CKC_X_509;
ck_object_handle_t obj;
int a_val;
gnutls_datum_t subject = { NULL, 0 };
ret = pkcs11_url_to_info (token_url, &info);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret =
pkcs11_open_session (&module, &pks, info,
SESSION_WRITE | pkcs11_obj_flags_to_int (flags));
p11_kit_uri_free (info);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = gnutls_x509_crt_export (crt, GNUTLS_X509_FMT_DER, NULL, &der_size);
if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
gnutls_assert ();
goto cleanup;
}
der = gnutls_malloc (der_size);
if (der == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
ret = gnutls_x509_crt_export (crt, GNUTLS_X509_FMT_DER, der, &der_size);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
id_size = sizeof (id);
ret = gnutls_x509_crt_get_key_id (crt, 0, id, &id_size);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = gnutls_x509_crt_get_raw_dn (crt, &subject);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
/* FIXME: copy key usage flags */
a[0].type = CKA_CLASS;
a[0].value = &class;
a[0].value_len = sizeof (class);
a[1].type = CKA_ID;
a[1].value = id;
a[1].value_len = id_size;
a[2].type = CKA_VALUE;
a[2].value = der;
a[2].value_len = der_size;
a[3].type = CKA_TOKEN;
a[3].value = (void*)&tval;
a[3].value_len = sizeof (tval);
a[4].type = CKA_CERTIFICATE_TYPE;
a[4].value = &type;
a[4].value_len = sizeof (type);
a_val = 5;
a[a_val].type = CKA_SUBJECT;
a[a_val].value = subject.data;
a[a_val].value_len = subject.size;
a_val++;
if (label)
{
a[a_val].type = CKA_LABEL;
a[a_val].value = (void *) label;
a[a_val].value_len = strlen (label);
a_val++;
}
if (flags & GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED)
{
a[a_val].type = CKA_TRUSTED;
a[a_val].value = (void*)&tval;
a[a_val].value_len = sizeof (tval);
a_val++;
a[a_val].type = CKA_PRIVATE;
a[a_val].value = (void*)&fval;
a[a_val].value_len = sizeof(fval);
a_val++;
}
else
{
if (flags & GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE)
{
a[a_val].type = CKA_PRIVATE;
a[a_val].value = (void*)&tval;
a[a_val].value_len = sizeof(tval);
a_val++;
}
else if (flags & GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE)
{
a[a_val].type = CKA_PRIVATE;
a[a_val].value = (void*)&fval;
a[a_val].value_len = sizeof(fval);
a_val++;
}
}
rv = pkcs11_create_object (module, pks, a, a_val, &obj);
if (rv != CKR_OK)
{
gnutls_assert ();
_gnutls_debug_log ("pkcs11: %s\n", pkcs11_strerror (rv));
ret = pkcs11_rv_to_err (rv);
goto cleanup;
}
/* generated!
*/
ret = 0;
cleanup:
gnutls_free (der);
pkcs11_close_session (module, pks);
_gnutls_free_datum(&subject);
return ret;
}
|
↓
|
_gnutls_recv_handshake
|
13
|
46
|
107
|
gnutls_handshake.c
|
int
_gnutls_recv_handshake (gnutls_session_t session,
gnutls_handshake_description_t type,
optional_t optional, gnutls_buffer_st* buf)
{
int ret;
handshake_buffer_st hsk;
ret =
_gnutls_handshake_io_recv_int (session, type, &hsk);
if (ret < 0)
{
if (optional == OPTIONAL_PACKET && ret == GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET)
{
if (buf) _gnutls_buffer_init(buf);
return 0;
}
if (ret == GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET)
_gnutls_audit_log(session, "Received unexpected handshake message '%s' (%d). Expected '%s' (%d)\n",
_gnutls_handshake2str(hsk.htype), (int)hsk.htype, _gnutls_handshake2str(type), (int)type);
return gnutls_assert_val_fatal(ret);
}
ret = _gnutls_handshake_hash_add_recvd (session, hsk.htype,
hsk.header, hsk.header_size,
hsk.data.data, hsk.data.length);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
switch (hsk.htype)
{
case GNUTLS_HANDSHAKE_CLIENT_HELLO_V2:
case GNUTLS_HANDSHAKE_CLIENT_HELLO:
case GNUTLS_HANDSHAKE_SERVER_HELLO:
if (hsk.htype == GNUTLS_HANDSHAKE_CLIENT_HELLO_V2)
ret = _gnutls_read_client_hello_v2 (session, hsk.data.data, hsk.data.length);
else
ret = _gnutls_recv_hello (session, hsk.data.data, hsk.data.length);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
goto cleanup; /* caller doesn't need dataptr */
break;
case GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST:
ret = _gnutls_recv_hello_verify_request (session, hsk.data.data, hsk.data.length);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
else
/* Signal our caller we have received a verification cookie
and ClientHello needs to be sent again. */
ret = 1;
goto cleanup; /* caller doesn't need dataptr */
break;
case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
if (hsk.data.length == 0)
ret = 0;
else
{
gnutls_assert();
ret = GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
goto cleanup;
}
break;
case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
case GNUTLS_HANDSHAKE_FINISHED:
case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET:
ret = hsk.data.length;
break;
default:
gnutls_assert ();
/* we shouldn't actually arrive here in any case .
* unexpected messages should be catched after _gnutls_handshake_io_recv_int()
*/
ret = GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET;
goto cleanup;
}
if (buf)
{
*buf = hsk.data;
return ret;
}
cleanup:
_gnutls_handshake_buffer_clear (&hsk);
return ret;
}
|
↓
|
cdk_pkt_alloc
|
13
|
46
|
78
|
opencdk/new-packet.c
|
cdk_error_t
cdk_pkt_alloc (cdk_packet_t * r_pkt, cdk_packet_type_t pkttype)
{
cdk_packet_t pkt;
int rc;
if (!r_pkt)
return CDK_Inv_Value;
rc = cdk_pkt_new (&pkt);
if (rc)
return rc;
switch (pkttype)
{
case CDK_PKT_USER_ID:
pkt->pkt.user_id = cdk_calloc (1, sizeof pkt->pkt.user_id);
if (!pkt->pkt.user_id)
return CDK_Out_Of_Core;
pkt->pkt.user_id->name = NULL;
break;
case CDK_PKT_PUBLIC_KEY:
case CDK_PKT_PUBLIC_SUBKEY:
pkt->pkt.public_key = cdk_calloc (1, sizeof *pkt->pkt.public_key);
if (!pkt->pkt.public_key)
return CDK_Out_Of_Core;
break;
case CDK_PKT_SECRET_KEY:
case CDK_PKT_SECRET_SUBKEY:
pkt->pkt.secret_key = cdk_calloc (1, sizeof *pkt->pkt.secret_key);
pkt->pkt.secret_key->pk =
cdk_calloc (1, sizeof *pkt->pkt.secret_key->pk);
if (!pkt->pkt.secret_key || !pkt->pkt.secret_key->pk)
return CDK_Out_Of_Core;
break;
case CDK_PKT_SIGNATURE:
pkt->pkt.signature = cdk_calloc (1, sizeof *pkt->pkt.signature);
if (!pkt->pkt.signature)
return CDK_Out_Of_Core;
break;
case CDK_PKT_PUBKEY_ENC:
pkt->pkt.pubkey_enc = cdk_calloc (1, sizeof *pkt->pkt.pubkey_enc);
if (!pkt->pkt.pubkey_enc)
return CDK_Out_Of_Core;
break;
case CDK_PKT_MDC:
pkt->pkt.mdc = cdk_calloc (1, sizeof *pkt->pkt.mdc);
if (!pkt->pkt.mdc)
return CDK_Out_Of_Core;
break;
case CDK_PKT_ONEPASS_SIG:
pkt->pkt.onepass_sig = cdk_calloc (1, sizeof *pkt->pkt.onepass_sig);
if (!pkt->pkt.onepass_sig)
return CDK_Out_Of_Core;
break;
case CDK_PKT_LITERAL:
/* FIXME: We would need the size of the file name to allocate extra
bytes, otherwise the result would be useless. */
pkt->pkt.literal = cdk_calloc (1, sizeof *pkt->pkt.literal);
if (!pkt->pkt.literal)
return CDK_Out_Of_Core;
pkt->pkt.literal->name = NULL;
break;
default:
return CDK_Not_Implemented;
}
pkt->pkttype = pkttype;
*r_pkt = pkt;
return 0;
}
|
↓
|
print_crldist
|
13
|
45
|
84
|
x509/output.c
|
static void
print_crldist (gnutls_buffer_st * str, gnutls_x509_crt_t cert)
{
char *buffer = NULL;
size_t size;
char str_ip[64];
char *p;
int err;
int indx;
for (indx = 0;; indx++)
{
size = 0;
err = gnutls_x509_crt_get_crl_dist_points (cert, indx, buffer, &size,
NULL, NULL);
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
return;
if (err != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
addf (str, "error: get_crl_dist_points: %s\n",
gnutls_strerror (err));
return;
}
buffer = gnutls_malloc (size);
if (!buffer)
{
addf (str, "error: malloc: %s\n",
gnutls_strerror (GNUTLS_E_MEMORY_ERROR));
return;
}
err = gnutls_x509_crt_get_crl_dist_points (cert, indx, buffer, &size,
NULL, NULL);
if (err < 0)
{
gnutls_free (buffer);
addf (str, "error: get_crl_dist_points2: %s\n",
gnutls_strerror (err));
return;
}
if ((err == GNUTLS_SAN_DNSNAME
|| err == GNUTLS_SAN_RFC822NAME
|| err == GNUTLS_SAN_URI) && strlen (buffer) != size)
{
adds (str, _("warning: distributionPoint contains an embedded NUL, "
"replacing with '!'\n"));
while (strlen (buffer) < size)
buffer[strlen (buffer)] = '!';
}
switch (err)
{
case GNUTLS_SAN_DNSNAME:
addf (str, "\t\t\tDNSname: %.*s\n", (int) size, buffer);
break;
case GNUTLS_SAN_RFC822NAME:
addf (str, "\t\t\tRFC822name: %.*s\n", (int) size, buffer);
break;
case GNUTLS_SAN_URI:
addf (str, "\t\t\tURI: %.*s\n", (int) size, buffer);
break;
case GNUTLS_SAN_IPADDRESS:
p = ip_to_string (buffer, size, str_ip, sizeof (str_ip));
if (p == NULL)
p = ERROR_STR;
addf (str, "\t\t\tIPAddress: %s\n", p);
break;
case GNUTLS_SAN_DN:
addf (str, "\t\t\tdirectoryName: %.*s\n", (int) size, buffer);
break;
default:
addf (str, "error: unknown SAN\n");
break;
}
gnutls_free (buffer);
}
}
|
↓
|
decrypt_data
|
13
|
64
|
131
|
x509/privkey_pkcs8.c
|
static int
decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn,
const char *root, const char *password,
const struct pbkdf2_params *kdf_params,
const struct pbe_enc_params *enc_params,
gnutls_datum_t * decrypted_data)
{
int result;
int data_size;
opaque *data = NULL, *key = NULL;
gnutls_datum_t dkey, d_iv;
cipher_hd_st ch;
int ch_init = 0;
int key_size;
data_size = 0;
result = asn1_read_value (pkcs8_asn, root, NULL, &data_size);
if (result != ASN1_MEM_ERROR)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
data = gnutls_malloc (data_size);
if (data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = asn1_read_value (pkcs8_asn, root, data, &data_size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
if (kdf_params->key_size == 0)
{
key_size = gnutls_cipher_get_key_size (enc_params->cipher);
}
else
key_size = kdf_params->key_size;
key = gnutls_malloc (key_size);
if (key == NULL)
{
gnutls_assert ();
result = GNUTLS_E_MEMORY_ERROR;
goto error;
}
/* generate the key
*/
switch (schema)
{
case PBES2_3DES:
case PBES2_AES_128:
case PBES2_AES_192:
case PBES2_AES_256:
result = _gnutls_pbkdf2_sha1 (password, strlen (password),
kdf_params->salt, kdf_params->salt_size,
kdf_params->iter_count, key, key_size);
if (result < 0)
{
gnutls_assert ();
goto error;
}
break;
default:
result =
_gnutls_pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt,
kdf_params->salt_size,
kdf_params->iter_count, password,
key_size, key);
if (result < 0)
{
gnutls_assert ();
goto error;
}
}
/* do the decryption.
*/
dkey.data = key;
dkey.size = key_size;
d_iv.data = (opaque *) enc_params->iv;
d_iv.size = enc_params->iv_size;
result = _gnutls_cipher_init (&ch, enc_params->cipher, &dkey, &d_iv, 0);
gnutls_free (key);
key = NULL;
if (result < 0)
{
gnutls_assert ();
goto error;
}
ch_init = 1;
result = _gnutls_cipher_decrypt (&ch, data, data_size);
if (result < 0)
{
gnutls_assert ();
goto error;
}
decrypted_data->data = data;
if (gnutls_cipher_get_block_size (enc_params->cipher) != 1)
decrypted_data->size = data_size - data[data_size - 1];
else
decrypted_data->size = data_size;
_gnutls_cipher_deinit (&ch);
return 0;
error:
gnutls_free (data);
gnutls_free (key);
if (ch_init != 0)
_gnutls_cipher_deinit (&ch);
return result;
}
|
↓
|
find_by_pattern
|
13
|
24
|
39
|
opencdk/keydb.c
|
static int
find_by_pattern (cdk_kbnode_t knode, cdk_keydb_search_t ks)
{
cdk_kbnode_t node;
size_t uidlen;
char *name;
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype != CDK_PKT_USER_ID)
continue;
if (node->pkt->pkt.user_id->attrib_img != NULL)
continue; /* Skip attribute packets. */
uidlen = node->pkt->pkt.user_id->len;
name = node->pkt->pkt.user_id->name;
switch (ks->type)
{
case CDK_DBSEARCH_EXACT:
if (name &&
(strlen (ks->u.pattern) == uidlen &&
!strncmp (ks->u.pattern, name, uidlen)))
return 1;
break;
case CDK_DBSEARCH_SUBSTR:
if (uidlen > 65536)
break;
if (name && strlen (ks->u.pattern) > uidlen)
break;
if (name && _cdk_memistr (name, uidlen, ks->u.pattern))
return 1;
break;
default: /* Invalid mode */
return 0;
}
}
return 0;
}
|
↓
|
encode_to_private_key_info
|
13
|
69
|
138
|
x509/privkey_pkcs8.c
|
static int
encode_to_private_key_info (gnutls_x509_privkey_t pkey,
gnutls_datum_t * der, ASN1_TYPE * pkey_info)
{
int result, len;
opaque null = 0;
const char *oid;
gnutls_datum_t algo_params = { NULL, 0 };
gnutls_datum_t algo_privkey = { NULL, 0 };
oid = _gnutls_x509_pk_to_oid(pkey->pk_algorithm);
if (oid == NULL)
{
gnutls_assert ();
return GNUTLS_E_UNIMPLEMENTED_FEATURE;
}
result =
_gnutls_x509_write_pubkey_params (pkey->pk_algorithm, &pkey->params, &algo_params);
if (result < 0)
{
gnutls_assert ();
return result;
}
if ((result =
asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-8-PrivateKeyInfo",
pkey_info)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Write the version.
*/
result = asn1_write_value (*pkey_info, "version", &null, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* write the privateKeyAlgorithm
* fields. (OID+NULL data)
*/
result =
asn1_write_value (*pkey_info, "privateKeyAlgorithm.algorithm", oid, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
result =
asn1_write_value (*pkey_info, "privateKeyAlgorithm.parameters",
algo_params.data, algo_params.size);
_gnutls_free_datum (&algo_params);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Write the raw private key
*/
result = _encode_privkey (pkey, &algo_privkey);
if (result < 0)
{
gnutls_assert ();
goto error;
}
result =
asn1_write_value (*pkey_info, "privateKey", algo_privkey.data,
algo_privkey.size);
_gnutls_free_datum (&algo_privkey);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Append an empty Attributes field.
*/
result = asn1_write_value (*pkey_info, "attributes", NULL, 0);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* DER Encode the generated private key info.
*/
len = 0;
result = asn1_der_coding (*pkey_info, "", NULL, &len, NULL);
if (result != ASN1_MEM_ERROR)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* allocate data for the der
*/
der->size = len;
der->data = gnutls_malloc (len);
if (der->data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = asn1_der_coding (*pkey_info, "", der->data, &len, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
return 0;
error:
asn1_delete_structure (pkey_info);
_gnutls_free_datum (&algo_params);
_gnutls_free_datum (&algo_privkey);
return result;
}
|
↓
|
print_req
|
13
|
67
|
113
|
x509/ocsp_output.c
|
static void
print_req (gnutls_buffer_st * str, gnutls_ocsp_req_t req)
{
int ret;
unsigned indx;
/* Version. */
{
int version = gnutls_ocsp_req_get_version (req);
if (version < 0)
addf (str, "error: get_version: %s\n", gnutls_strerror (version));
else
addf (str, _("\tVersion: %d\n"), version);
}
/* XXX requestorName */
/* requestList */
addf (str, "\tRequest List:\n");
for (indx = 0; ; indx++)
{
gnutls_digest_algorithm_t digest;
gnutls_datum_t in, ik, sn;
ret = gnutls_ocsp_req_get_cert_id (req, indx, &digest, &in, &ik, &sn);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
addf (str, "\t\tCertificate ID:\n");
if (ret != GNUTLS_E_SUCCESS)
{
addf (str, "error: get_cert_id: %s\n",
gnutls_strerror (ret));
continue;
}
addf (str, "\t\t\tHash Algorithm: %s\n",
_gnutls_digest_get_name (digest));
adds (str, "\t\t\tIssuer Name Hash: ");
_gnutls_buffer_hexprint (str, in.data, in.size);
adds (str, "\n");
adds (str, "\t\t\tIssuer Key Hash: ");
_gnutls_buffer_hexprint (str, ik.data, ik.size);
adds (str, "\n");
adds (str, "\t\t\tSerial Number: ");
_gnutls_buffer_hexprint (str, sn.data, sn.size);
adds (str, "\n");
gnutls_free (in.data);
gnutls_free (ik.data);
gnutls_free (sn.data);
/* XXX singleRequestExtensions */
}
for (indx = 0; ; indx++)
{
gnutls_datum_t oid;
unsigned int critical;
gnutls_datum_t data;
ret = gnutls_ocsp_req_get_extension (req, indx, &oid, &critical, &data);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
else if (ret != GNUTLS_E_SUCCESS)
{
addf (str, "error: get_extension: %s\n",
gnutls_strerror (ret));
continue;
}
if (indx == 0)
adds (str, "\tExtensions:\n");
if (memcmp (oid.data, GNUTLS_OCSP_NONCE, oid.size) == 0)
{
gnutls_datum_t nonce;
unsigned int critical;
ret = gnutls_ocsp_req_get_nonce (req, &critical, &nonce);
if (ret != GNUTLS_E_SUCCESS)
{
addf (str, "error: get_nonce: %s\n",
gnutls_strerror (ret));
}
else
{
addf (str, "\t\tNonce%s: ", critical ? " (critical)" : "");
_gnutls_buffer_hexprint (str, nonce.data, nonce.size);
adds (str, "\n");
gnutls_free (nonce.data);
}
}
else
{
addf (str, "\t\tUnknown extension %s (%s):\n", oid.data,
critical ? "critical" : "not critical");
addf (str, _("\t\t\tASCII: "));
_gnutls_buffer_asciiprint (str, data.data, data.size);
addf (str, "\n");
addf (str, _("\t\t\tHexdump: "));
_gnutls_buffer_hexprint (str, data.data, data.size);
adds (str, "\n");
}
gnutls_free (oid.data);
gnutls_free (data.data);
}
/* XXX Signature */
}
|
↓
|
_gnutls_x509_get_dn_oid
|
13
|
61
|
120
|
x509/dn.c
|
int
_gnutls_x509_get_dn_oid (ASN1_TYPE asn1_struct,
const char *asn1_rdn_name,
int indx, void *_oid, size_t * sizeof_oid)
{
int k2, k1, result;
char tmpbuffer1[ASN1_MAX_NAME_SIZE];
char tmpbuffer2[ASN1_MAX_NAME_SIZE];
char tmpbuffer3[ASN1_MAX_NAME_SIZE];
char value[256];
char oid[MAX_OID_SIZE];
int len;
int i = 0;
k1 = 0;
do
{
k1++;
/* create a string like "tbsCertList.issuer.rdnSequence.?1"
*/
if (asn1_rdn_name[0] != 0)
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", asn1_rdn_name,
k1);
else
snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1);
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer1, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
gnutls_assert ();
break;
}
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
k2 = 0;
do
{ /* Move to the attibute type and values
*/
k2++;
if (tmpbuffer1[0] != 0)
snprintf (tmpbuffer2, sizeof (tmpbuffer2), "%s.?%u", tmpbuffer1,
k2);
else
snprintf (tmpbuffer2, sizeof (tmpbuffer2), "?%u", k2);
/* Try to read the RelativeDistinguishedName attributes.
*/
len = sizeof (value) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer2, value, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
{
break;
}
if (result != ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Read the OID
*/
_gnutls_str_cpy (tmpbuffer3, sizeof (tmpbuffer3), tmpbuffer2);
_gnutls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type");
len = sizeof (oid) - 1;
result = asn1_read_value (asn1_struct, tmpbuffer3, oid, &len);
if (result == ASN1_ELEMENT_NOT_FOUND)
break;
else if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (indx == i++)
{ /* Found the OID */
len = strlen (oid) + 1;
if (*sizeof_oid < (unsigned) len)
{
*sizeof_oid = len;
gnutls_assert ();
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
memcpy (_oid, oid, len);
*sizeof_oid = len - 1;
return 0;
}
}
while (1);
}
while (1);
gnutls_assert ();
result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
cleanup:
return result;
}
|
↓
|
gnutls_pkcs12_set_bag
|
13
|
54
|
121
|
x509/pkcs12.c
|
int
gnutls_pkcs12_set_bag (gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
ASN1_TYPE safe_cont = ASN1_TYPE_EMPTY;
int result;
int enc = 0, dum = 1;
char null;
if (pkcs12 == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
/* Step 1. Check if the pkcs12 structure is empty. In that
* case generate an empty PFX.
*/
result = asn1_read_value (pkcs12->pkcs12, "authSafe.content", &null, &dum);
if (result == ASN1_VALUE_NOT_FOUND)
{
result = create_empty_pfx (pkcs12->pkcs12);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
/* Step 2. decode the authenticatedSafe.
*/
result = _decode_pkcs12_auth_safe (pkcs12->pkcs12, &c2, NULL);
if (result < 0)
{
gnutls_assert ();
return result;
}
/* Step 3. Encode the bag elements into a SafeContents
* structure.
*/
result = _pkcs12_encode_safe_contents (bag, &safe_cont, &enc);
if (result < 0)
{
gnutls_assert ();
return result;
}
/* Step 4. Insert the encoded SafeContents into the AuthenticatedSafe
* structure.
*/
result = asn1_write_value (c2, "", "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (enc)
result = asn1_write_value (c2, "?LAST.contentType", ENC_DATA_OID, 1);
else
result = asn1_write_value (c2, "?LAST.contentType", DATA_OID, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if (enc)
{
/* Encrypted packets are written directly.
*/
result =
asn1_write_value (c2, "?LAST.content",
bag->element[0].data.data,
bag->element[0].data.size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
}
else
{
result =
_gnutls_x509_der_encode_and_copy (safe_cont, "", c2,
"?LAST.content", 1);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
}
asn1_delete_structure (&safe_cont);
/* Step 5. Reencode and copy the AuthenticatedSafe into the pkcs12
* structure.
*/
result =
_gnutls_x509_der_encode_and_copy (c2, "", pkcs12->pkcs12,
"authSafe.content", 1);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
asn1_delete_structure (&c2);
return 0;
cleanup:
asn1_delete_structure (&c2);
asn1_delete_structure (&safe_cont);
return result;
}
|
↓
|
_gnutls_gen_srp_client_kx
|
13
|
54
|
106
|
auth/srp.c
|
int
_gnutls_gen_srp_client_kx (gnutls_session_t session, gnutls_buffer_st* data)
{
int ret;
char *username, *password;
gnutls_srp_client_credentials_t cred;
extension_priv_data_t epriv;
srp_ext_st *priv;
ret = _gnutls_ext_get_session_data (session, GNUTLS_EXTENSION_SRP, &epriv);
if (ret < 0) /* peer didn't send a username */
{
gnutls_assert ();
return GNUTLS_E_UNKNOWN_SRP_USERNAME;
}
priv = epriv.ptr;
cred = (gnutls_srp_client_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_SRP, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if (priv->username == NULL)
{
username = cred->username;
password = cred->password;
}
else
{
username = priv->username;
password = priv->password;
}
if (username == NULL || password == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* calc A = g^a % N
*/
if (G == NULL || N == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
A = _gnutls_calc_srp_A (&_a, G, N);
if (A == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* Rest of SRP calculations
*/
/* calculate u */
session->key->u = _gnutls_calc_srp_u (A, B, N);
if (session->key->u == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_mpi_log ("SRP U: ", session->key->u);
/* S = (B - g^x) ^ (a + u * x) % N */
S = _gnutls_calc_srp_S2 (B, G, session->key->x, _a, session->key->u, N);
if (S == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
_gnutls_mpi_log ("SRP B: ", B);
_gnutls_mpi_release (&_b);
_gnutls_mpi_release (&V);
_gnutls_mpi_release (&session->key->u);
_gnutls_mpi_release (&B);
ret = _gnutls_mpi_dprint (session->key->KEY, &session->key->key);
_gnutls_mpi_release (&S);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_buffer_append_mpi(data, 16, A, 0);
if (ret < 0)
return gnutls_assert_val(ret);
_gnutls_mpi_log ("SRP A: ", A);
_gnutls_mpi_release (&A);
return data->length;
}
|
↓
|
_gnutls_x509_cert_verify_peers
|
13
|
47
|
97
|
gnutls_x509.c
|
int
_gnutls_x509_cert_verify_peers (gnutls_session_t session,
unsigned int *status)
{
cert_auth_info_t info;
gnutls_certificate_credentials_t cred;
gnutls_x509_crt_t *peer_certificate_list;
int peer_certificate_list_size, i, x, ret;
CHECK_AUTH (GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
info = _gnutls_get_auth_info (session);
if (info == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if (info->raw_certificate_list == NULL || info->ncerts == 0)
return GNUTLS_E_NO_CERTIFICATE_FOUND;
if (info->ncerts > cred->verify_depth && cred->verify_depth > 0)
{
gnutls_assert ();
return GNUTLS_E_CONSTRAINT_ERROR;
}
/* generate a list of gnutls_certs based on the auth info
* raw certs.
*/
peer_certificate_list_size = info->ncerts;
peer_certificate_list =
gnutls_calloc (peer_certificate_list_size, sizeof (gnutls_x509_crt_t));
if (peer_certificate_list == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
for (i = 0; i < peer_certificate_list_size; i++)
{
ret = gnutls_x509_crt_init (&peer_certificate_list[i]);
if (ret < 0)
{
gnutls_assert ();
CLEAR_CERTS;
return ret;
}
ret =
gnutls_x509_crt_import (peer_certificate_list[i],
&info->raw_certificate_list[i],
GNUTLS_X509_FMT_DER);
if (ret < 0)
{
gnutls_assert ();
CLEAR_CERTS;
return ret;
}
ret = check_bits (peer_certificate_list[i], cred->verify_bits);
if (ret < 0)
{
gnutls_assert ();
CLEAR_CERTS;
return ret;
}
}
/* Verify certificate
*/
ret = gnutls_x509_trust_list_verify_crt (cred->tlist, peer_certificate_list,
peer_certificate_list_size,
cred->verify_flags | session->internals.
priorities.additional_verify_flags,
status, NULL);
CLEAR_CERTS;
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
|
↓
|
read_attribute
|
13
|
46
|
68
|
opencdk/read-packet.c
|
static cdk_error_t
read_attribute (cdk_stream_t inp, size_t pktlen, cdk_pkt_userid_t attr, int name_size)
{
const byte *p;
byte *buf;
size_t len, nread;
cdk_error_t rc;
if (!inp || !attr || !pktlen)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_attribute: %d octets\n", (int) pktlen);
_gnutls_str_cpy (attr->name, name_size, ATTRIBUTE);
attr->len = MIN(name_size, sizeof(ATTRIBUTE)-1);
buf = cdk_calloc (1, pktlen);
if (!buf)
return CDK_Out_Of_Core;
rc = stream_read (inp, buf, pktlen, &nread);
if (rc)
{
cdk_free (buf);
return CDK_Inv_Packet;
}
p = buf;
len = *p++;
pktlen--;
if (len == 255)
{
len = _cdk_buftou32 (p);
p += 4;
pktlen -= 4;
}
else if (len >= 192)
{
if (pktlen < 2)
{
cdk_free (buf);
return CDK_Inv_Packet;
}
len = ((len - 192) << 8) + *p + 192;
p++;
pktlen--;
}
if (*p != 1) /* Currently only 1, meaning an image, is defined. */
{
cdk_free (buf);
return CDK_Inv_Packet;
}
p++;
len--;
if (len >= pktlen)
return CDK_Inv_Packet;
attr->attrib_img = cdk_calloc (1, len);
if (!attr->attrib_img)
{
cdk_free (buf);
return CDK_Out_Of_Core;
}
attr->attrib_len = len;
memcpy (attr->attrib_img, p, len);
cdk_free (buf);
return rc;
}
|
↓
|
retrieve_pin_for_callback
|
13
|
45
|
73
|
pkcs11.c
|
static int
retrieve_pin_for_callback (struct ck_token_info *token_info, int attempts,
ck_user_type_t user_type, struct p11_kit_pin **pin)
{
char pin_value[GNUTLS_PKCS11_MAX_PIN_LEN];
unsigned int flags = 0;
char *token_str;
char *label;
struct p11_kit_uri *token_uri;
int ret = 0;
label = p11_kit_space_strdup (token_info->label, sizeof (token_info->label));
if (label == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
token_uri = p11_kit_uri_new ();
if (token_uri == NULL)
{
free (label);
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
memcpy (p11_kit_uri_get_token_info (token_uri), token_info,
sizeof (struct ck_token_info));
ret = pkcs11_info_to_url (token_uri, 1, &token_str);
p11_kit_uri_free (token_uri);
if (ret < 0)
{
free (label);
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
if (user_type == CKU_USER)
{
flags |= GNUTLS_PKCS11_PIN_USER;
if (token_info->flags & CKF_USER_PIN_COUNT_LOW)
flags |= GNUTLS_PKCS11_PIN_COUNT_LOW;
if (token_info->flags & CKF_USER_PIN_FINAL_TRY)
flags |= GNUTLS_PKCS11_PIN_FINAL_TRY;
}
else if (user_type == CKU_SO)
{
flags |= GNUTLS_PKCS11_PIN_SO;
if (token_info->flags & CKF_SO_PIN_COUNT_LOW)
flags |= GNUTLS_PKCS11_PIN_COUNT_LOW;
if (token_info->flags & CKF_SO_PIN_FINAL_TRY)
flags |= GNUTLS_PKCS11_PIN_FINAL_TRY;
}
if (attempts > 0)
flags |= GNUTLS_PKCS11_PIN_WRONG;
ret = pin_func (pin_data, attempts, (char*)token_str, label,
flags, pin_value, GNUTLS_PKCS11_MAX_PIN_LEN);
free (token_str);
free (label);
if (ret < 0)
return gnutls_assert_val(GNUTLS_E_PKCS11_PIN_ERROR);
*pin = p11_kit_pin_new_for_string (pin_value);
if (*pin == NULL)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
return 0;
}
|
↓
|
cdk_keydb_import
|
13
|
44
|
78
|
opencdk/keydb.c
|
cdk_error_t
cdk_keydb_import (cdk_keydb_hd_t hd, cdk_kbnode_t knode)
{
cdk_kbnode_t node, chk;
cdk_packet_t pkt;
cdk_stream_t out;
cdk_error_t rc;
u32 keyid[2];
if (!hd || !knode)
{
gnutls_assert ();
return CDK_Inv_Value;
}
pkt = find_key_packet (knode, NULL);
if (!pkt)
{
gnutls_assert ();
return CDK_Inv_Packet;
}
_cdk_pkt_get_keyid (pkt, keyid);
chk = NULL;
cdk_keydb_get_bykeyid (hd, keyid, &chk);
if (chk)
{ /* FIXME: search for new signatures */
cdk_kbnode_release (chk);
return 0;
}
/* We append data to the stream so we need to close
the stream here to re-open it later. */
if (hd->fp)
{
cdk_stream_close (hd->fp);
hd->fp = NULL;
}
rc = _cdk_stream_append (hd->name, &out);
if (rc)
{
gnutls_assert ();
return rc;
}
for (node = knode; node; node = node->next)
{
if (node->pkt->pkttype == CDK_PKT_RING_TRUST)
continue; /* No uniformed syntax for this packet */
if (node->pkt->pkttype == CDK_PKT_SIGNATURE &&
!node->pkt->pkt.signature->flags.exportable)
{
_cdk_log_debug ("key db import: skip local signature\n");
continue;
}
if (!is_key_node (node))
{
_cdk_log_debug ("key db import: skip invalid node of type %d\n",
node->pkt->pkttype);
continue;
}
rc = cdk_pkt_write (out, node->pkt);
if (rc)
{
cdk_stream_close (out);
gnutls_assert ();
return rc;
}
}
cdk_stream_close (out);
hd->stats.new_keys++;
return 0;
}
|
↓
|
pkcs11_obj_import_pubkey
|
13
|
43
|
96
|
pkcs11.c
|
static int
pkcs11_obj_import_pubkey (struct ck_function_list *module,
ck_session_handle_t pks,
ck_object_handle_t obj,
gnutls_pkcs11_obj_t crt,
const gnutls_datum_t * id,
const gnutls_datum_t * label,
struct ck_token_info *tinfo,
struct ck_info *lib_info)
{
struct ck_attribute a[4];
ck_key_type_t key_type;
int ret;
ck_bool_t tval;
a[0].type = CKA_KEY_TYPE;
a[0].value = &key_type;
a[0].value_len = sizeof (key_type);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
crt->pk_algorithm = mech_to_pk(key_type);
ret = read_pkcs11_pubkey(module, pks, obj, key_type, crt->pubkey);
if (ret < 0)
return gnutls_assert_val(ret);
}
/* read key usage flags */
a[0].type = CKA_ENCRYPT;
a[0].value = &tval;
a[0].value_len = sizeof (tval);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
if (tval != 0)
{
crt->key_usage |= GNUTLS_KEY_DATA_ENCIPHERMENT;
}
}
a[0].type = CKA_VERIFY;
a[0].value = &tval;
a[0].value_len = sizeof (tval);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
if (tval != 0)
{
crt->key_usage |= GNUTLS_KEY_DIGITAL_SIGNATURE |
GNUTLS_KEY_KEY_CERT_SIGN | GNUTLS_KEY_CRL_SIGN
| GNUTLS_KEY_NON_REPUDIATION;
}
}
a[0].type = CKA_VERIFY_RECOVER;
a[0].value = &tval;
a[0].value_len = sizeof (tval);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
if (tval != 0)
{
crt->key_usage |= GNUTLS_KEY_DIGITAL_SIGNATURE |
GNUTLS_KEY_KEY_CERT_SIGN | GNUTLS_KEY_CRL_SIGN
| GNUTLS_KEY_NON_REPUDIATION;
}
}
a[0].type = CKA_DERIVE;
a[0].value = &tval;
a[0].value_len = sizeof (tval);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
if (tval != 0)
{
crt->key_usage |= GNUTLS_KEY_KEY_AGREEMENT;
}
}
a[0].type = CKA_WRAP;
a[0].value = &tval;
a[0].value_len = sizeof (tval);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
if (tval != 0)
{
crt->key_usage |= GNUTLS_KEY_KEY_ENCIPHERMENT;
}
}
return pkcs11_obj_import (CKO_PUBLIC_KEY, crt, NULL, id, label,
tinfo, lib_info);
}
|
↓
|
read_subpkt
|
13
|
42
|
56
|
opencdk/read-packet.c
|
static cdk_error_t
read_subpkt (cdk_stream_t inp, cdk_subpkt_t * r_ctx, size_t * r_nbytes)
{
byte c, c1;
size_t size, nread, n;
cdk_subpkt_t node;
cdk_error_t rc;
if (!inp || !r_nbytes)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_subpkt:\n");
n = 0;
*r_nbytes = 0;
c = cdk_stream_getc (inp);
n++;
if (c == 255)
{
size = read_32 (inp);
n += 4;
}
else if (c >= 192 && c < 255)
{
c1 = cdk_stream_getc (inp);
n++;
if (c1 == 0)
return 0;
size = ((c - 192) << 8) + c1 + 192;
}
else if (c < 192)
size = c;
else
return CDK_Inv_Packet;
node = cdk_subpkt_new (size);
if (!node)
return CDK_Out_Of_Core;
node->size = size;
node->type = cdk_stream_getc (inp);
if (DEBUG_PKT)
_gnutls_write_log (" %d octets %d type\n", node->size, node->type);
n++;
node->size--;
rc = stream_read (inp, node->d, node->size, &nread);
n += nread;
if (rc)
return rc;
*r_nbytes = n;
if (!*r_ctx)
*r_ctx = node;
else
cdk_subpkt_add (*r_ctx, node);
return rc;
}
|
↓
|
cdk_keydb_export
|
13
|
42
|
69
|
opencdk/keydb.c
|
cdk_error_t
cdk_keydb_export (cdk_keydb_hd_t hd, cdk_stream_t out, cdk_strlist_t remusr)
{
cdk_kbnode_t knode, node;
cdk_strlist_t r;
cdk_error_t rc;
int old_ctb;
cdk_keydb_search_t st;
for (r = remusr; r; r = r->next)
{
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_AUTO, r->d);
if (rc)
{
gnutls_assert ();
return rc;
}
rc = cdk_keydb_search (st, hd, &knode);
cdk_keydb_search_release (st);
if (rc)
{
gnutls_assert ();
return rc;
}
node = cdk_kbnode_find (knode, CDK_PKT_PUBLIC_KEY);
if (!node)
{
gnutls_assert ();
return CDK_Error_No_Key;
}
/* If the key is a version 3 key, use the old packet
format for the output. */
if (node->pkt->pkt.public_key->version == 3)
old_ctb = 1;
else
old_ctb = 0;
for (node = knode; node; node = node->next)
{
/* No specified format; skip them */
if (node->pkt->pkttype == CDK_PKT_RING_TRUST)
continue;
/* We never export local signed signatures */
if (node->pkt->pkttype == CDK_PKT_SIGNATURE &&
!node->pkt->pkt.signature->flags.exportable)
continue;
/* Filter out invalid signatures */
if (node->pkt->pkttype == CDK_PKT_SIGNATURE &&
(!KEY_CAN_SIGN (node->pkt->pkt.signature->pubkey_algo)))
continue;
/* Adjust the ctb flag if needed. */
node->pkt->old_ctb = old_ctb;
rc = cdk_pkt_write (out, node->pkt);
if (rc)
{
cdk_kbnode_release (knode);
gnutls_assert ();
return rc;
}
}
cdk_kbnode_release (knode);
knode = NULL;
}
return 0;
}
|
↓
|
gnutls_ocsp_req_add_cert_id
|
13
|
38
|
89
|
x509/ocsp.c
|
int
gnutls_ocsp_req_add_cert_id (gnutls_ocsp_req_t req,
gnutls_digest_algorithm_t digest,
const gnutls_datum_t *issuer_name_hash,
const gnutls_datum_t *issuer_key_hash,
const gnutls_datum_t *serial_number)
{
int result;
const char *oid;
if (req == NULL || issuer_name_hash == NULL
|| issuer_key_hash == NULL || serial_number == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
oid = _gnutls_x509_digest_to_oid (digest);
if (oid == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
result = asn1_write_value (req->req, "tbsRequest.requestList", "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
result = asn1_write_value
(req->req, "tbsRequest.requestList.?LAST.reqCert.hashAlgorithm.algorithm",
oid, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
/* XXX we don't support any algorithm with parameters */
result = asn1_write_value
(req->req, "tbsRequest.requestList.?LAST.reqCert.hashAlgorithm.parameters",
ASN1_NULL, ASN1_NULL_SIZE);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
result = asn1_write_value
(req->req, "tbsRequest.requestList.?LAST.reqCert.issuerNameHash",
issuer_name_hash->data, issuer_name_hash->size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
result = asn1_write_value
(req->req, "tbsRequest.requestList.?LAST.reqCert.issuerKeyHash",
issuer_key_hash->data, issuer_key_hash->size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
result = asn1_write_value
(req->req, "tbsRequest.requestList.?LAST.reqCert.serialNumber",
serial_number->data, serial_number->size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
/* XXX add separate function that can add extensions too */
result = asn1_write_value
(req->req, "tbsRequest.requestList.?LAST.singleRequestExtensions",
NULL, 0);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
return GNUTLS_E_SUCCESS;
}
|
↓
|
_gnutls_gen_cert_server_cert_req
|
13
|
38
|
82
|
auth/cert.c
|
int
_gnutls_gen_cert_server_cert_req (gnutls_session_t session,
gnutls_buffer_st * data)
{
gnutls_certificate_credentials_t cred;
int size, ret;
uint8_t tmp_data[CERTTYPE_SIZE];
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
/* Now we need to generate the RDN sequence. This is
* already in the CERTIFICATE_CRED structure, to improve
* performance.
*/
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
size = CERTTYPE_SIZE + 2; /* 2 for gnutls_certificate_type_t + 2 for size of rdn_seq
*/
if (session->security_parameters.cert_type == GNUTLS_CRT_X509 &&
session->internals.ignore_rdn_sequence == 0)
size += cred->x509_rdn_sequence.size;
if (_gnutls_version_has_selectable_sighash (ver))
/* Need two bytes to announce the number of supported hash
functions (see below). */
size += MAX_SIGN_ALGO_SIZE;
tmp_data[0] = CERTTYPE_SIZE - 1;
tmp_data[1] = RSA_SIGN;
tmp_data[2] = DSA_SIGN;
tmp_data[3] = ECDSA_SIGN; /* only these for now */
ret = _gnutls_buffer_append_data (data, tmp_data, CERTTYPE_SIZE);
if (ret < 0)
return gnutls_assert_val (ret);
if (_gnutls_version_has_selectable_sighash (ver))
{
uint8_t p[MAX_SIGN_ALGO_SIZE];
ret =
_gnutls_sign_algorithm_write_params (session, p, MAX_SIGN_ALGO_SIZE);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* recalculate size */
size -= MAX_SIGN_ALGO_SIZE + ret;
ret = _gnutls_buffer_append_data (data, p, ret);
if (ret < 0)
return gnutls_assert_val (ret);
}
if (session->security_parameters.cert_type == GNUTLS_CRT_X509 &&
session->internals.ignore_rdn_sequence == 0)
{
ret =
_gnutls_buffer_append_data_prefix (data, 16,
cred->x509_rdn_sequence.data,
cred->x509_rdn_sequence.size);
if (ret < 0)
return gnutls_assert_val (ret);
}
else
{
ret = _gnutls_buffer_append_prefix (data, 16, 0);
if (ret < 0)
return gnutls_assert_val (ret);
}
return data->length;
}
|
↓
|
read_literal
|
13
|
31
|
42
|
opencdk/read-packet.c
|
static cdk_error_t
read_literal (cdk_stream_t inp, size_t pktlen,
cdk_pkt_literal_t * ret_pt, int is_partial)
{
cdk_pkt_literal_t pt = *ret_pt;
size_t nread;
cdk_error_t rc;
if (!inp || !pt)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_literal: %d octets\n", (int) pktlen);
pt->mode = cdk_stream_getc (inp);
if (pt->mode != 0x62 && pt->mode != 0x74 && pt->mode != 0x75)
return CDK_Inv_Packet;
if (cdk_stream_eof (inp))
return CDK_Inv_Packet;
pt->namelen = cdk_stream_getc (inp);
if (pt->namelen > 0)
{
*ret_pt = pt = cdk_realloc (pt, sizeof *pt + pt->namelen + 2);
if (!pt)
return CDK_Out_Of_Core;
pt->name = (char *) pt + sizeof (*pt);
rc = stream_read (inp, pt->name, pt->namelen, &nread);
if (rc)
return rc;
if ((int) nread != pt->namelen)
return CDK_Inv_Packet;
pt->name[pt->namelen] = '\0';
}
pt->timestamp = read_32 (inp);
pktlen = pktlen - 6 - pt->namelen;
if (is_partial)
_cdk_stream_set_blockmode (inp, pktlen);
pt->buf = inp;
pt->len = pktlen;
return 0;
}
|
↓
|
write_v3_sig
|
13
|
29
|
35
|
opencdk/write-packet.c
|
static cdk_error_t
write_v3_sig (cdk_stream_t out, cdk_pkt_signature_t sig, int nsig)
{
size_t size;
cdk_error_t rc;
size = 19 + calc_mpisize (sig->mpi, nsig);
if (is_RSA (sig->pubkey_algo))
rc = pkt_write_head2 (out, size, CDK_PKT_SIGNATURE);
else
rc = pkt_write_head (out, 1, size, CDK_PKT_SIGNATURE);
if (!rc)
rc = stream_putc (out, sig->version);
if (!rc)
rc = stream_putc (out, 5);
if (!rc)
rc = stream_putc (out, sig->sig_class);
if (!rc)
rc = write_32 (out, sig->timestamp);
if (!rc)
rc = write_32 (out, sig->keyid[0]);
if (!rc)
rc = write_32 (out, sig->keyid[1]);
if (!rc)
rc = stream_putc (out, _cdk_pub_algo_to_pgp (sig->pubkey_algo));
if (!rc)
rc = stream_putc (out, _gnutls_hash_algo_to_pgp (sig->digest_algo));
if (!rc)
rc = stream_putc (out, sig->digest_start[0]);
if (!rc)
rc = stream_putc (out, sig->digest_start[1]);
if (!rc)
rc = write_mpibuf (out, sig->mpi, nsig);
return rc;
}
|
↓
|
print_key_usage
|
13
|
28
|
39
|
x509/output.c
|
static void
print_key_usage (gnutls_buffer_st * str, const char *prefix, int type,
cert_type_t cert)
{
unsigned int key_usage;
int err;
if (type == TYPE_CRT)
err = gnutls_x509_crt_get_key_usage (cert.crt, &key_usage, NULL);
else if (type == TYPE_CRQ)
err = gnutls_x509_crq_get_key_usage (cert.crq, &key_usage, NULL);
else
return;
if (err < 0)
{
addf (str, "error: get_key_usage: %s\n", gnutls_strerror (err));
return;
}
if (key_usage & GNUTLS_KEY_DIGITAL_SIGNATURE)
addf (str, _("%s\t\t\tDigital signature.\n"), prefix);
if (key_usage & GNUTLS_KEY_NON_REPUDIATION)
addf (str, _("%s\t\t\tNon repudiation.\n"), prefix);
if (key_usage & GNUTLS_KEY_KEY_ENCIPHERMENT)
addf (str, _("%s\t\t\tKey encipherment.\n"), prefix);
if (key_usage & GNUTLS_KEY_DATA_ENCIPHERMENT)
addf (str, _("%s\t\t\tData encipherment.\n"), prefix);
if (key_usage & GNUTLS_KEY_KEY_AGREEMENT)
addf (str, _("%s\t\t\tKey agreement.\n"), prefix);
if (key_usage & GNUTLS_KEY_KEY_CERT_SIGN)
addf (str, _("%s\t\t\tCertificate signing.\n"), prefix);
if (key_usage & GNUTLS_KEY_CRL_SIGN)
addf (str, _("%s\t\t\tCRL signing.\n"), prefix);
if (key_usage & GNUTLS_KEY_ENCIPHER_ONLY)
addf (str, _("%s\t\t\tKey encipher only.\n"), prefix);
if (key_usage & GNUTLS_KEY_DECIPHER_ONLY)
addf (str, _("%s\t\t\tKey decipher only.\n"), prefix);
}
|
↓
|
get_last_packet
|
13
|
26
|
58
|
gnutls_buffers.c
|
static int get_last_packet(gnutls_session_t session, gnutls_handshake_description_t htype,
handshake_buffer_st * hsk)
{
handshake_buffer_st* recv_buf = session->internals.handshake_recv_buffer;
if (IS_DTLS(session))
{
if (session->internals.handshake_recv_buffer_size == 0 ||
(session->internals.dtls.hsk_read_seq != recv_buf[LAST_ELEMENT].sequence))
goto timeout;
if (htype != recv_buf[LAST_ELEMENT].htype)
{
hsk->htype = recv_buf[LAST_ELEMENT].htype;
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET);
}
else if ((recv_buf[LAST_ELEMENT].start_offset == 0 &&
recv_buf[LAST_ELEMENT].end_offset == recv_buf[LAST_ELEMENT].length -1) ||
recv_buf[LAST_ELEMENT].length == 0)
{
session->internals.dtls.hsk_read_seq++;
_gnutls_handshake_buffer_move(hsk, &recv_buf[LAST_ELEMENT]);
session->internals.handshake_recv_buffer_size--;
return 0;
}
else
goto timeout;
}
else /* TLS */
{
if (session->internals.handshake_recv_buffer_size > 0 && recv_buf[0].length == recv_buf[0].data.length)
{
if (cmp_hsk_types(htype, recv_buf[0].htype) == 0)
{
hsk->htype = recv_buf[LAST_ELEMENT].htype;
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET);
}
_gnutls_handshake_buffer_move(hsk, &recv_buf[0]);
session->internals.handshake_recv_buffer_size--;
return 0;
}
else
return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
}
timeout:
if (time(0)-session->internals.dtls.handshake_start_time > session->internals.dtls.total_timeout/1000)
return gnutls_assert_val(GNUTLS_E_TIMEDOUT);
else
{
if (session->internals.dtls.blocking != 0)
millisleep(50);
return gnutls_assert_val(GNUTLS_E_AGAIN);
}
}
|
↓
|
keydb_idx_search
|
13
|
21
|
40
|
opencdk/keydb.c
|
static cdk_error_t
keydb_idx_search (cdk_stream_t inp, u32 * keyid, const byte * fpr,
off_t * r_off)
{
key_idx_t idx;
if (!inp || !r_off)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if ((keyid && fpr) || (!keyid && !fpr))
{
gnutls_assert ();
return CDK_Inv_Mode;
}
/* We need an initialize the offset var with a value
because it might be possible the returned offset will
be 0 and then we cannot differ between the begin and an EOF. */
*r_off = 0xFFFFFFFF;
cdk_stream_seek (inp, 0);
while (keydb_idx_parse (inp, &idx) != CDK_EOF)
{
if (keyid && KEYID_CMP (keyid, idx->keyid))
{
*r_off = idx->offset;
break;
}
else if (fpr && !memcmp (idx->fpr, fpr, KEY_FPR_LEN))
{
*r_off = idx->offset;
break;
}
cdk_free (idx);
idx = NULL;
}
cdk_free (idx);
return *r_off != 0xFFFFFFFF ? 0 : CDK_EOF;
}
|
↓
|
generate_key
|
12
|
57
|
137
|
x509/privkey_pkcs8.c
|
static int
generate_key (schema_id schema,
const char *password,
struct pbkdf2_params *kdf_params,
struct pbe_enc_params *enc_params, gnutls_datum_t * key)
{
opaque rnd[2];
int ret;
ret = _gnutls_rnd (GNUTLS_RND_RANDOM, rnd, 2);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* generate salt */
kdf_params->salt_size =
MIN (sizeof (kdf_params->salt), (unsigned) (10 + (rnd[1] % 10)));
switch (schema)
{
case PBES2_3DES:
enc_params->cipher = GNUTLS_CIPHER_3DES_CBC;
break;
case PBES2_AES_128:
enc_params->cipher = GNUTLS_CIPHER_AES_128_CBC;
break;
case PBES2_AES_192:
enc_params->cipher = GNUTLS_CIPHER_AES_192_CBC;
break;
case PBES2_AES_256:
enc_params->cipher = GNUTLS_CIPHER_AES_256_CBC;
break;
/* non PBES2 algorithms */
case PKCS12_ARCFOUR_SHA1:
enc_params->cipher = GNUTLS_CIPHER_ARCFOUR_128;
kdf_params->salt_size = 8;
break;
case PKCS12_3DES_SHA1:
enc_params->cipher = GNUTLS_CIPHER_3DES_CBC;
kdf_params->salt_size = 8;
break;
case PKCS12_RC2_40_SHA1:
enc_params->cipher = GNUTLS_CIPHER_RC2_40_CBC;
kdf_params->salt_size = 8;
break;
default:
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
ret = _gnutls_rnd (GNUTLS_RND_RANDOM, kdf_params->salt,
kdf_params->salt_size);
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_RANDOM_FAILED;
}
kdf_params->iter_count = 256 + rnd[0];
key->size = kdf_params->key_size =
gnutls_cipher_get_key_size (enc_params->cipher);
enc_params->iv_size = _gnutls_cipher_get_iv_size (enc_params->cipher);
key->data = gnutls_malloc (key->size);
if (key->data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* now generate the key.
*/
switch (schema)
{
case PBES2_3DES:
case PBES2_AES_128:
case PBES2_AES_192:
case PBES2_AES_256:
ret = _gnutls_pbkdf2_sha1 (password, strlen (password),
kdf_params->salt, kdf_params->salt_size,
kdf_params->iter_count,
key->data, kdf_params->key_size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (enc_params->iv_size)
{
ret = _gnutls_rnd (GNUTLS_RND_NONCE,
enc_params->iv, enc_params->iv_size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
}
break;
default:
ret =
_gnutls_pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt,
kdf_params->salt_size,
kdf_params->iter_count, password,
kdf_params->key_size, key->data);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* Now generate the IV
*/
if (enc_params->iv_size)
{
ret =
_gnutls_pkcs12_string_to_key (2 /*IV*/, kdf_params->salt,
kdf_params->salt_size,
kdf_params->iter_count, password,
enc_params->iv_size,
enc_params->iv);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
}
}
return 0;
}
|
↓
|
pkcs11_obj_import
|
12
|
44
|
83
|
pkcs11.c
|
static int
pkcs11_obj_import (ck_object_class_t class, gnutls_pkcs11_obj_t obj,
const gnutls_datum_t * data,
const gnutls_datum_t * id,
const gnutls_datum_t * label,
struct ck_token_info *tinfo, struct ck_info *lib_info)
{
struct ck_attribute attr;
int ret;
switch (class)
{
case CKO_CERTIFICATE:
obj->type = GNUTLS_PKCS11_OBJ_X509_CRT;
break;
case CKO_PUBLIC_KEY:
obj->type = GNUTLS_PKCS11_OBJ_PUBKEY;
break;
case CKO_PRIVATE_KEY:
obj->type = GNUTLS_PKCS11_OBJ_PRIVKEY;
break;
case CKO_SECRET_KEY:
obj->type = GNUTLS_PKCS11_OBJ_SECRET_KEY;
break;
case CKO_DATA:
obj->type = GNUTLS_PKCS11_OBJ_DATA;
break;
default:
obj->type = GNUTLS_PKCS11_OBJ_UNKNOWN;
}
attr.type = CKA_CLASS;
attr.value = &class;
attr.value_len = sizeof (class);
ret = p11_kit_uri_set_attribute (obj->info, &attr);
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
if (data && data->data)
{
ret = _gnutls_set_datum (&obj->raw, data->data, data->size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
}
/* copy the token and library info into the uri */
memcpy (p11_kit_uri_get_token_info (obj->info), tinfo, sizeof (struct ck_token_info));
memcpy (p11_kit_uri_get_module_info (obj->info), lib_info, sizeof (struct ck_info));
if (label && label->data)
{
attr.type = CKA_LABEL;
attr.value = label->data;
attr.value_len = label->size;
ret = p11_kit_uri_set_attribute (obj->info, &attr);
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
}
if (id && id->data)
{
attr.type = CKA_ID;
attr.value = id->data;
attr.value_len = id->size;
ret = p11_kit_uri_set_attribute (obj->info, &attr);
if (ret < 0)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
}
return 0;
}
|
↓
|
_gnutls_session_unpack
|
12
|
48
|
103
|
gnutls_session_pack.c
|
int
_gnutls_session_unpack (gnutls_session_t session,
const gnutls_datum_t * packed_session)
{
int ret;
gnutls_buffer_st sb;
opaque id;
_gnutls_buffer_init (&sb);
if (packed_session == NULL || packed_session->size == 0)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
ret =
_gnutls_buffer_append_data (&sb, packed_session->data,
packed_session->size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (_gnutls_get_auth_info (session) != NULL)
{
_gnutls_free_auth_info (session);
}
BUFFER_POP (&sb, &id, 1);
switch (id)
{
#ifdef ENABLE_SRP
case GNUTLS_CRD_SRP:
ret = unpack_srp_auth_info (session, &sb);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
break;
#endif
#ifdef ENABLE_PSK
case GNUTLS_CRD_PSK:
ret = unpack_psk_auth_info (session, &sb);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
break;
#endif
#ifdef ENABLE_ANON
case GNUTLS_CRD_ANON:
ret = unpack_anon_auth_info (session, &sb);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
break;
#endif
case GNUTLS_CRD_CERTIFICATE:
ret = unpack_certificate_auth_info (session, &sb);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
break;
default:
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto error;
}
/* Auth_info structures copied. Now copy security_parameters_st.
* packed_session must have allocated space for the security parameters.
*/
ret = unpack_security_parameters (session, &sb);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
ret = _gnutls_ext_unpack (session, &sb);
if (ret < 0)
{
gnutls_assert ();
goto error;
}
ret = 0;
error:
_gnutls_buffer_clear (&sb);
return ret;
}
|
↓
|
_pkcs12_encode_crt_bag
|
12
|
55
|
111
|
x509/pkcs12_bag.c
|
int
_pkcs12_encode_crt_bag (gnutls_pkcs12_bag_type_t type,
const gnutls_datum_t * raw, gnutls_datum_t * out)
{
int ret;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
switch (type)
{
case GNUTLS_BAG_CERTIFICATE:
if ((ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-CertBag",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = asn1_write_value (c2, "certId", X509_CERT_OID, 1);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_write_value (c2, "certValue", raw, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
case GNUTLS_BAG_CRL:
if ((ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-CRLBag",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = asn1_write_value (c2, "crlId", X509_CRL_OID, 1);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_write_value (c2, "crlValue", raw, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
case GNUTLS_BAG_SECRET:
if ((ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-SecretBag",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = asn1_write_value (c2, "secretTypeId", RANDOM_NONCE_OID, 1);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_write_value (c2, "secretValue", raw, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
default:
gnutls_assert ();
asn1_delete_structure (&c2);
return GNUTLS_E_UNIMPLEMENTED_FEATURE;
}
ret = _gnutls_x509_der_encode (c2, "", out, 0);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
asn1_delete_structure (&c2);
return 0;
cleanup:
asn1_delete_structure (&c2);
return ret;
}
|
↓
|
_gnutls_handshake_sign_cert_vrfy
|
12
|
47
|
95
|
gnutls_sig.c
|
int
_gnutls_handshake_sign_cert_vrfy (gnutls_session_t session,
gnutls_pcert_st* cert, gnutls_privkey_t pkey,
gnutls_datum_t * signature)
{
gnutls_datum_t dconcat;
int ret;
opaque concat[MAX_SIG_SIZE];
digest_hd_st td_md5;
digest_hd_st td_sha;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
gnutls_pk_algorithm_t pk = gnutls_pubkey_get_pk_algorithm(cert->pubkey, NULL);
if (_gnutls_version_has_selectable_sighash(ver))
return _gnutls_handshake_sign_cert_vrfy12 (session, cert, pkey,
signature);
ret =
_gnutls_hash_init (&td_sha, GNUTLS_DIG_SHA1);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_hash(&td_sha, session->internals.handshake_hash_buffer.data, session->internals.handshake_hash_buffer.length);
if (ver == GNUTLS_SSL3)
{
ret = _gnutls_generate_master (session, 1);
if (ret < 0)
{
gnutls_assert ();
_gnutls_hash_deinit (&td_sha, NULL);
return ret;
}
ret = _gnutls_mac_deinit_ssl3_handshake (&td_sha, &concat[16],
session->
security_parameters.master_secret,
GNUTLS_MASTER_SIZE);
if (ret < 0)
return gnutls_assert_val(ret);
}
else
_gnutls_hash_deinit (&td_sha, &concat[16]);
/* ensure 1024 bit DSA keys are used */
ret = _gnutls_pubkey_compatible_with_sig(cert->pubkey, ver, GNUTLS_SIGN_UNKNOWN);
if (ret < 0)
return gnutls_assert_val(ret);
switch (pk)
{
case GNUTLS_PK_RSA:
ret =
_gnutls_hash_init (&td_md5, GNUTLS_DIG_MD5);
if (ret < 0)
return gnutls_assert_val(ret);
_gnutls_hash(&td_md5, session->internals.handshake_hash_buffer.data, session->internals.handshake_hash_buffer.length);
if (ver == GNUTLS_SSL3)
{
ret = _gnutls_mac_deinit_ssl3_handshake (&td_md5, concat,
session->
security_parameters.master_secret,
GNUTLS_MASTER_SIZE);
if (ret < 0)
return gnutls_assert_val(ret);
}
else
_gnutls_hash_deinit (&td_md5, concat);
dconcat.data = concat;
dconcat.size = 36;
break;
case GNUTLS_PK_DSA:
case GNUTLS_PK_EC:
dconcat.data = &concat[16];
dconcat.size = 20;
break;
default:
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
}
ret = sign_tls_hash (session, GNUTLS_DIG_NULL, cert, pkey, &dconcat, signature);
if (ret < 0)
{
gnutls_assert ();
}
return ret;
}
|
↓
|
_gnutls_gen_srp_server_kx
|
12
|
63
|
125
|
auth/srp.c
|
int
_gnutls_gen_srp_server_kx (gnutls_session_t session, gnutls_buffer_st* data)
{
int ret;
char *username;
SRP_PWD_ENTRY *pwd_entry;
srp_server_auth_info_t info;
size_t tmp_size;
extension_priv_data_t epriv;
srp_ext_st *priv;
ret = _gnutls_ext_get_session_data (session, GNUTLS_EXTENSION_SRP, &epriv);
if (ret < 0) /* peer didn't send a username */
{
gnutls_assert ();
return GNUTLS_E_UNKNOWN_SRP_USERNAME;
}
priv = epriv.ptr;
if ((ret =
_gnutls_auth_info_set (session, GNUTLS_CRD_SRP,
sizeof (srp_server_auth_info_st), 1)) < 0)
{
gnutls_assert ();
return ret;
}
info = _gnutls_get_auth_info (session);
username = info->username;
_gnutls_str_cpy (username, MAX_USERNAME_SIZE, priv->username);
ret = _gnutls_srp_pwd_read_entry (session, username, &pwd_entry);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* copy from pwd_entry to local variables (actually in session) */
tmp_size = pwd_entry->g.size;
if (_gnutls_mpi_scan_nz (&G, pwd_entry->g.data, tmp_size) < 0)
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
tmp_size = pwd_entry->n.size;
if (_gnutls_mpi_scan_nz (&N, pwd_entry->n.data, tmp_size) < 0)
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
tmp_size = pwd_entry->v.size;
if (_gnutls_mpi_scan_nz (&V, pwd_entry->v.data, tmp_size) < 0)
{
gnutls_assert ();
ret = GNUTLS_E_MPI_SCAN_FAILED;
goto cleanup;
}
/* Calculate: B = (k*v + g^b) % N
*/
B = _gnutls_calc_srp_B (&_b, G, N, V);
if (B == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
/* copy N (mod n)
*/
ret = _gnutls_buffer_append_data_prefix( data, 16, pwd_entry->n.data,
pwd_entry->n.size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
/* copy G (generator) to data
*/
ret = _gnutls_buffer_append_data_prefix( data, 16, pwd_entry->g.data,
pwd_entry->g.size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
/* copy the salt
*/
ret = _gnutls_buffer_append_data_prefix( data, 8, pwd_entry->salt.data,
pwd_entry->salt.size);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
/* Copy the B value
*/
ret = _gnutls_buffer_append_mpi( data, 16, B, 0);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
_gnutls_mpi_log ("SRP B: ", B);
_gnutls_srp_entry_free (pwd_entry);
ret = data->length;
cleanup:
_gnutls_srp_entry_free (pwd_entry);
return ret;
}
|
↓
|
_gnutls_pkcs7_encrypt_data
|
12
|
62
|
136
|
x509/privkey_pkcs8.c
|
int
_gnutls_pkcs7_encrypt_data (schema_id schema,
const gnutls_datum_t * data,
const char *password, gnutls_datum_t * enc)
{
int result;
gnutls_datum_t key = { NULL, 0 };
gnutls_datum_t tmp = { NULL, 0 };
ASN1_TYPE pkcs7_asn = ASN1_TYPE_EMPTY;
struct pbkdf2_params kdf_params;
struct pbe_enc_params enc_params;
const char *str_oid;
if ((result =
asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-7-EncryptedData",
&pkcs7_asn)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Write the encryption schema OID
*/
result = schema_to_oid (schema, &str_oid);
if (result < 0)
{
gnutls_assert ();
return result;
}
result =
asn1_write_value (pkcs7_asn,
"encryptedContentInfo.contentEncryptionAlgorithm.algorithm",
str_oid, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Generate a symmetric key.
*/
result = generate_key (schema, password, &kdf_params, &enc_params, &key);
if (result < 0)
{
gnutls_assert ();
goto error;
}
result = write_schema_params (schema, pkcs7_asn,
"encryptedContentInfo.contentEncryptionAlgorithm.parameters",
&kdf_params, &enc_params);
if (result < 0)
{
gnutls_assert ();
goto error;
}
/* Parameters have been encoded. Now
* encrypt the Data.
*/
result = encrypt_data (data, &enc_params, &key, &tmp);
if (result < 0)
{
gnutls_assert ();
goto error;
}
/* write the encrypted data.
*/
result =
asn1_write_value (pkcs7_asn,
"encryptedContentInfo.encryptedContent", tmp.data,
tmp.size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
_gnutls_free_datum (&tmp);
_gnutls_free_datum (&key);
/* Now write the rest of the pkcs-7 stuff.
*/
result = _gnutls_x509_write_uint32 (pkcs7_asn, "version", 0);
if (result < 0)
{
gnutls_assert ();
goto error;
}
result =
asn1_write_value (pkcs7_asn, "encryptedContentInfo.contentType",
DATA_OID, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
result = asn1_write_value (pkcs7_asn, "unprotectedAttrs", NULL, 0);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* Now encode and copy the DER stuff.
*/
result = _gnutls_x509_der_encode (pkcs7_asn, "", enc, 0);
asn1_delete_structure (&pkcs7_asn);
if (result < 0)
{
gnutls_assert ();
goto error;
}
error:
_gnutls_free_datum (&key);
_gnutls_free_datum (&tmp);
asn1_delete_structure (&pkcs7_asn);
return result;
}
|
↓
|
_gnutls_x509_encode_and_write_attribute
|
12
|
61
|
124
|
x509/dn.c
|
int
_gnutls_x509_encode_and_write_attribute (const char *given_oid,
ASN1_TYPE asn1_struct,
const char *where,
const void *_data,
int sizeof_data, int multi)
{
const char *val_name;
const opaque *data = _data;
char tmp[128];
ASN1_TYPE c2;
int result;
/* Find how to encode the data.
*/
val_name = _gnutls_x509_oid2asn_string (given_oid);
if (val_name == NULL)
{
gnutls_assert ();
_gnutls_debug_log ("Cannot find OID: %s\n", given_oid);
return GNUTLS_E_X509_UNSUPPORTED_OID;
}
result = asn1_create_element (_gnutls_get_pkix (), val_name, &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
tmp[0] = 0;
if ((result = _gnutls_x509_oid_data_choice (given_oid)) > 0)
{
const char *string_type;
int i;
string_type = "printableString";
/* Check if the data is plain ascii, and use
* the UTF8 string type if not.
*/
for (i = 0; i < sizeof_data; i++)
{
if (!isascii (data[i]))
{
string_type = "utf8String";
break;
}
}
/* if the type is a CHOICE then write the
* type we'll use.
*/
result = asn1_write_value (c2, "", string_type, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
_gnutls_str_cpy (tmp, sizeof (tmp), string_type);
}
result = asn1_write_value (c2, tmp, data, sizeof_data);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* write the data (value)
*/
_gnutls_str_cpy (tmp, sizeof (tmp), where);
_gnutls_str_cat (tmp, sizeof (tmp), ".value");
if (multi != 0)
{ /* if not writing an AttributeTypeAndValue, but an Attribute */
_gnutls_str_cat (tmp, sizeof (tmp), "s"); /* values */
result = asn1_write_value (asn1_struct, tmp, "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
_gnutls_str_cat (tmp, sizeof (tmp), ".?LAST");
}
result = _gnutls_x509_der_encode_and_copy (c2, "", asn1_struct, tmp, 0);
if (result < 0)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
/* write the type
*/
_gnutls_str_cpy (tmp, sizeof (tmp), where);
_gnutls_str_cat (tmp, sizeof (tmp), ".type");
result = asn1_write_value (asn1_struct, tmp, given_oid, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto error;
}
result = 0;
error:
asn1_delete_structure (&c2);
return result;
}
|
↓
|
gnutls_x509_crq_get_extension_info
|
12
|
59
|
106
|
x509/crq.c
|
int
gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t crq, int indx,
void *oid, size_t * sizeof_oid,
unsigned int *critical)
{
int result;
char str_critical[10];
char name[ASN1_MAX_NAME_SIZE];
char *extensions = NULL;
size_t extensions_size = 0;
ASN1_TYPE c2;
int len;
if (!crq)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
/* read extensionRequest */
result = gnutls_x509_crq_get_attribute_by_oid (crq, "1.2.840.113549.1.9.14",
0, NULL, &extensions_size);
if (result == GNUTLS_E_SHORT_MEMORY_BUFFER)
{
extensions = gnutls_malloc (extensions_size);
if (extensions == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = gnutls_x509_crq_get_attribute_by_oid (crq,
"1.2.840.113549.1.9.14",
0, extensions,
&extensions_size);
}
if (result < 0)
{
gnutls_assert ();
goto out;
}
result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto out;
}
result = asn1_der_decoding (&c2, extensions, extensions_size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
result = _gnutls_asn2err (result);
goto out;
}
snprintf (name, sizeof (name), "?%u.extnID", indx + 1);
len = *sizeof_oid;
result = asn1_read_value (c2, name, oid, &len);
*sizeof_oid = len;
if (result == ASN1_ELEMENT_NOT_FOUND)
{
asn1_delete_structure (&c2);
result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
goto out;
}
else if (result < 0)
{
gnutls_assert ();
asn1_delete_structure (&c2);
result = _gnutls_asn2err (result);
goto out;
}
snprintf (name, sizeof (name), "?%u.critical", indx + 1);
len = sizeof (str_critical);
result = asn1_read_value (c2, name, str_critical, &len);
asn1_delete_structure (&c2);
if (result < 0)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto out;
}
if (critical)
{
if (str_critical[0] == 'T')
*critical = 1;
else
*critical = 0;
}
result = 0;
out:
gnutls_free (extensions);
return result;
}
|
↓
|
gnutls_pkcs12_generate_mac
|
12
|
56
|
122
|
x509/pkcs12.c
|
int
gnutls_pkcs12_generate_mac (gnutls_pkcs12_t pkcs12, const char *pass)
{
opaque salt[8], key[20];
int result;
const int iter = 1;
digest_hd_st td1;
gnutls_datum_t tmp = { NULL, 0 };
opaque sha_mac[20];
if (pkcs12 == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
/* Generate the salt.
*/
result = _gnutls_rnd (GNUTLS_RND_NONCE, salt, sizeof (salt));
if (result < 0)
{
gnutls_assert ();
return result;
}
/* Write the salt into the structure.
*/
result =
asn1_write_value (pkcs12->pkcs12, "macData.macSalt", salt, sizeof (salt));
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* write the iterations
*/
if (iter > 1)
{
result =
_gnutls_x509_write_uint32 (pkcs12->pkcs12, "macData.iterations",
iter);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
}
/* Generate the key.
*/
result = _gnutls_pkcs12_string_to_key (3 /*MAC*/, salt, sizeof (salt),
iter, pass, sizeof (key), key);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
/* Get the data to be MACed
*/
result = _decode_pkcs12_auth_safe (pkcs12->pkcs12, NULL, &tmp);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
/* MAC the data
*/
result = _gnutls_hmac_init (&td1, GNUTLS_MAC_SHA1, key, sizeof (key));
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
_gnutls_hmac (&td1, tmp.data, tmp.size);
_gnutls_free_datum (&tmp);
_gnutls_hmac_deinit (&td1, sha_mac);
result =
asn1_write_value (pkcs12->pkcs12, "macData.mac.digest", sha_mac,
sizeof (sha_mac));
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
result =
asn1_write_value (pkcs12->pkcs12,
"macData.mac.digestAlgorithm.parameters", NULL, 0);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
result =
asn1_write_value (pkcs12->pkcs12,
"macData.mac.digestAlgorithm.algorithm", HASH_OID_SHA1,
1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
return 0;
cleanup:
_gnutls_free_datum (&tmp);
return result;
}
|
↓
|
parse_pem_cert_mem
|
12
|
55
|
103
|
gnutls_x509.c
|
static int
parse_pem_cert_mem (gnutls_certificate_credentials_t res,
const char *input_cert, int input_cert_size)
{
int size;
const char *ptr;
gnutls_datum_t tmp;
int ret, count, i;
gnutls_pcert_st *certs = NULL;
gnutls_str_array_t names;
_gnutls_str_array_init(&names);
/* move to the certificate
*/
ptr = memmem (input_cert, input_cert_size,
PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
if (ptr == NULL)
ptr = memmem (input_cert, input_cert_size,
PEM_CERT_SEP2, sizeof (PEM_CERT_SEP2) - 1);
if (ptr == NULL)
{
gnutls_assert ();
return GNUTLS_E_BASE64_DECODING_ERROR;
}
size = input_cert_size - (ptr - input_cert);
count = 0;
do
{
certs = gnutls_realloc_fast (certs, (count + 1) * sizeof (gnutls_pcert_st));
if (certs == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
tmp.data = (void*)ptr;
tmp.size = size;
if (count == 0)
{
ret = get_x509_name_raw(&tmp, GNUTLS_X509_FMT_PEM, &names);
if (ret < 0)
{
gnutls_assert();
goto cleanup;
}
}
ret = gnutls_pcert_import_x509_raw (&certs[count], &tmp, GNUTLS_X509_FMT_PEM, 0);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
/* now we move ptr after the pem header
*/
ptr++;
/* find the next certificate (if any)
*/
size = input_cert_size - (ptr - input_cert);
if (size > 0)
{
char *ptr3;
ptr3 = memmem (ptr, size, PEM_CERT_SEP, sizeof (PEM_CERT_SEP) - 1);
if (ptr3 == NULL)
ptr3 = memmem (ptr, size, PEM_CERT_SEP2,
sizeof (PEM_CERT_SEP2) - 1);
ptr = ptr3;
}
else
ptr = NULL;
count++;
}
while (ptr != NULL);
ret = certificate_credential_append_crt_list (res, names, certs, count);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
return count;
cleanup:
_gnutls_str_array_clear(&names);
for (i=0;i
|
↓
|
gnutls_ocsp_resp_get_certs
|
12
|
54
|
88
|
x509/ocsp.c
|
int
gnutls_ocsp_resp_get_certs (gnutls_ocsp_resp_t resp,
gnutls_x509_crt_t ** certs,
size_t *ncerts)
{
int ret;
size_t ctr = 0, i;
gnutls_x509_crt_t *tmpcerts = NULL, *tmpcerts2;
gnutls_datum_t c = { NULL, 0 };
if (resp == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
tmpcerts = gnutls_malloc (sizeof (*tmpcerts));
if (tmpcerts == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
for (;;)
{
char name[ASN1_MAX_NAME_SIZE];
snprintf (name, sizeof (name), "certs.?%lu", ctr + 1);
ret = _gnutls_x509_der_encode (resp->basicresp, name, &c, 0);
if (ret == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
break;
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
goto error;
}
tmpcerts2 = gnutls_realloc (tmpcerts, (ctr + 2) * sizeof (*tmpcerts));
if (tmpcerts2 == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto error;
}
tmpcerts = tmpcerts2;
ret = gnutls_x509_crt_init (&tmpcerts[ctr]);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
goto error;
}
ctr++;
ret = gnutls_x509_crt_import (tmpcerts[ctr - 1], &c,
GNUTLS_X509_FMT_DER);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
goto error;
}
gnutls_free (c.data);
c.data = NULL;
}
tmpcerts[ctr] = NULL;
if (ncerts)
*ncerts = ctr;
if (certs)
*certs = tmpcerts;
else
{
/* clean up memory */
ret = GNUTLS_E_SUCCESS;
goto error;
}
return GNUTLS_E_SUCCESS;
error:
gnutls_free (c.data);
for (i = 0; i < ctr; i++)
gnutls_x509_crt_deinit (tmpcerts[i]);
gnutls_free (tmpcerts);
return ret;
}
|
↓
|
_gnutls_proc_cert_cert_req
|
12
|
54
|
106
|
auth/cert.c
|
int
_gnutls_proc_cert_cert_req (gnutls_session_t session, opaque * data,
size_t data_size)
{
int size, ret;
opaque *p;
gnutls_certificate_credentials_t cred;
ssize_t dsize;
int i;
gnutls_pk_algorithm_t pk_algos[MAX_CLIENT_SIGN_ALGOS];
int pk_algos_length;
gnutls_protocol_t ver = gnutls_protocol_get_version (session);
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
if ((ret =
_gnutls_auth_info_set (session, GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 0)) < 0)
{
gnutls_assert ();
return ret;
}
p = data;
dsize = data_size;
DECR_LEN (dsize, 1);
size = p[0];
p++;
/* check if the sign algorithm is supported.
*/
pk_algos_length = 0;
for (i = 0; i < size; i++, p++)
{
DECR_LEN (dsize, 1);
if ((ret = _gnutls_check_supported_sign_algo (*p)) > 0)
{
if (pk_algos_length < MAX_CLIENT_SIGN_ALGOS)
{
pk_algos[pk_algos_length++] = ret;
}
}
}
if (pk_algos_length == 0)
{
gnutls_assert ();
return GNUTLS_E_UNKNOWN_PK_ALGORITHM;
}
if (_gnutls_version_has_selectable_sighash (ver))
{
/* read supported hashes */
int hash_num;
DECR_LEN (dsize, 2);
hash_num = _gnutls_read_uint16 (p);
p += 2;
DECR_LEN (dsize, hash_num);
ret = _gnutls_sign_algorithm_parse_data (session, p, hash_num);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
p += hash_num;
}
/* read the certificate authorities */
DECR_LEN (dsize, 2);
size = _gnutls_read_uint16 (p);
p += 2;
if (session->security_parameters.cert_type == GNUTLS_CRT_OPENPGP
&& size != 0)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
DECR_LEN (dsize, size);
/* now we ask the user to tell which one
* he wants to use.
*/
if ((ret =
_select_client_cert (session, p, size, pk_algos, pk_algos_length)) < 0)
{
gnutls_assert ();
return ret;
}
/* We should reply with a certificate message,
* even if we have no certificate to send.
*/
session->key->certificate_requested = 1;
return 0;
}
|
↓
|
_gnutls_privkey_decode_pkcs1_rsa_key
|
12
|
51
|
108
|
x509/privkey.c
|
ASN1_TYPE
_gnutls_privkey_decode_pkcs1_rsa_key (const gnutls_datum_t * raw_key,
gnutls_x509_privkey_t pkey)
{
int result;
ASN1_TYPE pkey_asn;
gnutls_pk_params_init(&pkey->params);
if ((result =
asn1_create_element (_gnutls_get_gnutls_asn (),
"GNUTLS.RSAPrivateKey",
&pkey_asn)) != ASN1_SUCCESS)
{
gnutls_assert ();
return NULL;
}
result = asn1_der_decoding (&pkey_asn, raw_key->data, raw_key->size, NULL);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
goto error;
}
if ((result = _gnutls_x509_read_int (pkey_asn, "modulus",
&pkey->params.params[0])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result =
_gnutls_x509_read_int (pkey_asn, "publicExponent",
&pkey->params.params[1])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result =
_gnutls_x509_read_int (pkey_asn, "privateExponent",
&pkey->params.params[2])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result = _gnutls_x509_read_int (pkey_asn, "prime1",
&pkey->params.params[3])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result = _gnutls_x509_read_int (pkey_asn, "prime2",
&pkey->params.params[4])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result = _gnutls_x509_read_int (pkey_asn, "coefficient",
&pkey->params.params[5])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result = _gnutls_x509_read_int (pkey_asn, "exponent1",
&pkey->params.params[6])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
if ((result = _gnutls_x509_read_int (pkey_asn, "exponent2",
&pkey->params.params[7])) < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr++;
result = _gnutls_pk_fixup (GNUTLS_PK_RSA, GNUTLS_IMPORT, &pkey->params);
if (result < 0)
{
gnutls_assert ();
goto error;
}
pkey->params.params_nr = RSA_PRIVATE_PARAMS;
return pkey_asn;
error:
asn1_delete_structure (&pkey_asn);
gnutls_pk_params_release (&pkey->params);
return NULL;
}
|
↓
|
gen_rsa_export_server_kx
|
12
|
49
|
98
|
auth/rsa_export.c
|
static int
gen_rsa_export_server_kx (gnutls_session_t session, gnutls_buffer_st* data)
{
gnutls_rsa_params_t rsa_params;
const gnutls_pk_params_st *rsa_mpis;
int ret = 0;
gnutls_pcert_st *apr_cert_list;
gnutls_privkey_t apr_pkey;
int apr_cert_list_length;
gnutls_datum_t signature, ddata;
gnutls_certificate_credentials_t cred;
gnutls_sign_algorithm_t sign_algo;
unsigned int bits = 0;
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
return ret;
}
/* abort sending this message if we have a certificate
* of 512 bits or less.
*/
gnutls_privkey_get_pk_algorithm (apr_pkey, &bits);
if (apr_pkey && bits <= 512)
{
gnutls_assert ();
return GNUTLS_E_INT_RET_0;
}
rsa_params =
_gnutls_certificate_get_rsa_params (cred->rsa_params, cred->params_func,
session);
rsa_mpis = _gnutls_rsa_params_to_mpi (rsa_params);
if (rsa_mpis == NULL)
{
gnutls_assert ();
return GNUTLS_E_NO_TEMPORARY_RSA_PARAMS;
}
if ((ret = _gnutls_auth_info_set (session, GNUTLS_CRD_CERTIFICATE,
sizeof (cert_auth_info_st), 0)) < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_rsa_export_set_pubkey (session, rsa_mpis->params[1], rsa_mpis->params[0]);
ret = _gnutls_buffer_append_mpi( data, 16, rsa_mpis->params[0], 0);
if (ret < 0)
return gnutls_assert_val(ret);
ret = _gnutls_buffer_append_mpi( data, 16, rsa_mpis->params[1], 0);
if (ret < 0)
return gnutls_assert_val(ret);
/* Generate the signature. */
ddata.data = data->data;
ddata.size = data->length;
if (apr_cert_list_length > 0)
{
if ((ret =
_gnutls_handshake_sign_data (session, &apr_cert_list[0],
apr_pkey, &ddata, &signature,
&sign_algo)) < 0)
{
gnutls_assert ();
return ret;
}
}
else
{
gnutls_assert ();
return data->length; /* do not put a signature - ILLEGAL! */
}
ret = _gnutls_buffer_append_data_prefix( data, 16, signature.data, signature.size);
_gnutls_free_datum (&signature);
if (ret < 0)
return gnutls_assert_val(ret);
return data->length;
}
|
↓
|
write_attributes
|
12
|
47
|
107
|
x509/pkcs12.c
|
static int
write_attributes (gnutls_pkcs12_bag_t bag, int elem,
ASN1_TYPE c2, const char *where)
{
int result;
char root[128];
/* If the bag attributes are empty, then write
* nothing to the attribute field.
*/
if (bag->element[elem].friendly_name == NULL &&
bag->element[elem].local_key_id.data == NULL)
{
/* no attributes
*/
result = asn1_write_value (c2, where, NULL, 0);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
return 0;
}
if (bag->element[elem].local_key_id.data != NULL)
{
/* Add a new Attribute
*/
result = asn1_write_value (c2, where, "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
_gnutls_str_cpy (root, sizeof (root), where);
_gnutls_str_cat (root, sizeof (root), ".?LAST");
result =
_gnutls_x509_encode_and_write_attribute (KEY_ID_OID, c2, root,
bag->
element[elem].local_key_id.
data,
bag->
element[elem].local_key_id.
size, 1);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
if (bag->element[elem].friendly_name != NULL)
{
opaque *name;
int size, i;
const char *p;
/* Add a new Attribute
*/
result = asn1_write_value (c2, where, "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
/* convert name to BMPString
*/
size = strlen (bag->element[elem].friendly_name) * 2;
name = gnutls_malloc (size);
if (name == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
p = bag->element[elem].friendly_name;
for (i = 0; i < size; i += 2)
{
name[i] = 0;
name[i + 1] = *p;
p++;
}
_gnutls_str_cpy (root, sizeof (root), where);
_gnutls_str_cat (root, sizeof (root), ".?LAST");
result =
_gnutls_x509_encode_and_write_attribute (FRIENDLY_NAME_OID, c2,
root, name, size, 1);
gnutls_free (name);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
return 0;
}
|
↓
|
_cdk_subpkt_get_array
|
12
|
44
|
62
|
opencdk/new-packet.c
|
byte *
_cdk_subpkt_get_array (cdk_subpkt_t s, int count, size_t * r_nbytes)
{
cdk_subpkt_t list;
byte *buf;
size_t n, nbytes;
if (!s)
{
if (r_nbytes)
*r_nbytes = 0;
return NULL;
}
for (n = 0, list = s; list; list = list->next)
{
n++; /* type */
n += list->size;
if (list->size < 192)
n++;
else if (list->size < 8384)
n += 2;
else
n += 5;
}
buf = cdk_calloc (1, n + 1);
if (!buf)
return NULL;
n = 0;
for (list = s; list; list = list->next)
{
nbytes = 1 + list->size; /* type */
if (nbytes < 192)
buf[n++] = nbytes;
else if (nbytes < 8384)
{
buf[n++] = nbytes / 256 + 192;
buf[n++] = nbytes % 256;
}
else
{
buf[n++] = 0xFF;
buf[n++] = nbytes >> 24;
buf[n++] = nbytes >> 16;
buf[n++] = nbytes >> 8;
buf[n++] = nbytes;
}
buf[n++] = list->type;
memcpy (buf + n, list->d, list->size);
n += list->size;
}
if (count)
{
cdk_free (buf);
buf = NULL;
}
if (r_nbytes)
*r_nbytes = n;
return buf;
}
|
↓
|
armor_encode
|
12
|
44
|
66
|
opencdk/armor.c
|
static cdk_error_t
armor_encode (void *data, FILE * in, FILE * out)
{
armor_filter_t *afx = data;
struct stat statbuf;
char crcbuf[5], buf[128], raw[49];
byte crcbuf2[3];
size_t nread = 0;
const char *lf;
if (!afx)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (afx->idx < 0 || afx->idx > (int) DIM (armor_begin) ||
afx->idx2 < 0 || afx->idx2 > (int) DIM (armor_end))
{
gnutls_assert ();
return CDK_Inv_Value;
}
_gnutls_buffers_log ("armor filter: encode\n");
memset (crcbuf, 0, sizeof (crcbuf));
lf = afx->le ? afx->le : LF;
fprintf (out, "-----%s-----%s", armor_begin[afx->idx], lf);
fprintf (out, "Version: OpenPrivacy " PACKAGE_VERSION "%s", lf);
if (afx->hdrlines)
fwrite (afx->hdrlines, 1, strlen (afx->hdrlines), out);
fprintf (out, "%s", lf);
if (fstat (fileno (in), &statbuf))
{
gnutls_assert ();
return CDK_General_Error;
}
while (!feof (in))
{
nread = fread (raw, 1, DIM (raw) - 1, in);
if (!nread)
break;
if (ferror (in))
{
gnutls_assert ();
return CDK_File_Error;
}
afx->crc = update_crc (afx->crc, (byte *) raw, nread);
base64_encode (buf, (byte *) raw, nread, DIM (buf) - 1);
fprintf (out, "%s%s", buf, lf);
}
crcbuf2[0] = afx->crc >> 16;
crcbuf2[1] = afx->crc >> 8;
crcbuf2[2] = afx->crc;
crcbuf[0] = b64chars[crcbuf2[0] >> 2];
crcbuf[1] = b64chars[((crcbuf2[0] << 4) & 0x30) | (crcbuf2[1] >> 4)];
crcbuf[2] = b64chars[((crcbuf2[1] << 2) & 0x3c) | (crcbuf2[2] >> 6)];
crcbuf[3] = b64chars[crcbuf2[2] & 0x3f];
fprintf (out, "=%s%s", crcbuf, lf);
fprintf (out, "-----%s-----%s", armor_end[afx->idx2], lf);
return 0;
}
|
↓
|
_gnutls_gen_openpgp_certificate_fpr
|
12
|
43
|
78
|
auth/cert.c
|
static int
_gnutls_gen_openpgp_certificate_fpr (gnutls_session_t session,
gnutls_buffer_st * data)
{
int ret, packet_size;
uint8_t type, fpr[20];
size_t fpr_size;
gnutls_pcert_st *apr_cert_list;
gnutls_privkey_t apr_pkey;
int apr_cert_list_length;
unsigned int use_subkey = 0;
/* find the appropriate certificate */
if ((ret =
_gnutls_get_selected_cert (session, &apr_cert_list,
&apr_cert_list_length, &apr_pkey)) < 0)
{
gnutls_assert ();
return ret;
}
fpr_size = sizeof (fpr);
ret =
gnutls_pubkey_get_openpgp_key_id (apr_cert_list[0].pubkey, 0, fpr,
&fpr_size, &use_subkey);
if (ret < 0)
return gnutls_assert_val (ret);
packet_size = 3 + 1;
if (use_subkey)
packet_size += 1 + fpr_size; /* for the keyid */
/* Only v4 fingerprints are sent
*/
if (apr_cert_list_length > 0)
packet_size += 20 + 1;
else /* empty certificate case */
return _gnutls_gen_openpgp_certificate (session, data);
ret = _gnutls_buffer_append_prefix (data, 24, packet_size - 3);
if (ret < 0)
return gnutls_assert_val (ret);
if (use_subkey)
{
type = PGP_KEY_FINGERPRINT_SUBKEY;
ret = _gnutls_buffer_append_data (data, &type, 1);
if (ret < 0)
return gnutls_assert_val (ret);
ret = _gnutls_buffer_append_data_prefix (data, 8, fpr, fpr_size);
if (ret < 0)
return gnutls_assert_val (ret);
}
else
{
type = PGP_KEY_FINGERPRINT; /* key fingerprint */
ret = _gnutls_buffer_append_data (data, &type, 1);
if (ret < 0)
return gnutls_assert_val (ret);
}
fpr_size = sizeof (fpr);
if ((ret =
_gnutls_openpgp_fingerprint (&apr_cert_list[0].cert, fpr,
&fpr_size)) < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_buffer_append_data_prefix (data, 8, fpr, fpr_size);
if (ret < 0)
return gnutls_assert_val (ret);
return data->length;
}
|
↓
|
cdk_stream_mmap_part
|
12
|
42
|
67
|
opencdk/stream.c
|
cdk_error_t
cdk_stream_mmap_part (cdk_stream_t s, off_t off, size_t len,
byte ** ret_buf, size_t * ret_buflen)
{
cdk_error_t rc;
off_t oldpos;
unsigned int n;
if (!ret_buf || !ret_buflen)
{
gnutls_assert ();
return CDK_Inv_Value;
}
*ret_buf = NULL;
*ret_buflen = 0;
if (!s)
{
gnutls_assert ();
return CDK_Inv_Value;
}
/* Memory mapping is not supported on custom I/O objects. */
if (s->cbs_hd)
{
_gnutls_read_log ("cdk_stream_mmap_part: not supported on callbacks\n");
gnutls_assert ();
return CDK_Inv_Mode;
}
oldpos = cdk_stream_tell (s);
rc = cdk_stream_flush (s);
if (rc)
{
gnutls_assert ();
return rc;
}
rc = cdk_stream_seek (s, off);
if (rc)
{
gnutls_assert ();
return rc;
}
if (!len)
len = cdk_stream_get_length (s);
if (!len)
{
_gnutls_read_log ("cdk_stream_mmap_part: invalid file size %lu\n", (unsigned long)len);
gnutls_assert ();
return s->error;
}
if (len > MAX_MAP_SIZE)
{
gnutls_assert ();
return CDK_Too_Short;
}
*ret_buf = cdk_calloc (1, len + 1);
*ret_buflen = len;
n = cdk_stream_read (s, *ret_buf, len);
if (n != len)
*ret_buflen = n;
rc = cdk_stream_seek (s, oldpos);
if (rc)
gnutls_assert ();
return rc;
}
|
↓
|
_gnutls_recv_finished
|
12
|
40
|
93
|
gnutls_handshake.c
|
static int
_gnutls_recv_finished (gnutls_session_t session)
{
uint8_t data[MAX_VERIFY_DATA_SIZE], *vrfy;
gnutls_buffer_st buf;
int data_size;
int ret;
int vrfy_size;
ret =
_gnutls_recv_handshake (session, GNUTLS_HANDSHAKE_FINISHED,
MANDATORY_PACKET, &buf);
if (ret < 0)
{
ERR ("recv finished int", ret);
gnutls_assert ();
return ret;
}
vrfy = buf.data;
vrfy_size = buf.length;
if (gnutls_protocol_get_version (session) == GNUTLS_SSL3)
{
data_size = 36;
}
else
{
data_size = 12;
}
if (vrfy_size != data_size)
{
gnutls_assert ();
ret = GNUTLS_E_ERROR_IN_FINISHED_PACKET;
goto cleanup;
}
if (gnutls_protocol_get_version (session) == GNUTLS_SSL3)
{
ret =
_gnutls_ssl3_finished (session,
(session->security_parameters.entity + 1) % 2,
data, 0);
}
else
{ /* TLS 1.0 */
ret =
_gnutls_finished (session,
(session->security_parameters.entity +
1) % 2, data, 0);
}
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
if (memcmp (vrfy, data, data_size) != 0)
{
gnutls_assert ();
ret = GNUTLS_E_ERROR_IN_FINISHED_PACKET;
goto cleanup;
}
ret = _gnutls_ext_sr_finished (session, data, data_size, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
if ((session->internals.resumed != RESUME_FALSE
&& session->security_parameters.entity == GNUTLS_CLIENT)
|| (session->internals.resumed == RESUME_FALSE
&& session->security_parameters.entity == GNUTLS_SERVER))
{
/* if we are a client resuming - or we are a server not resuming */
_gnutls_handshake_log ("HSK[%p]: recording tls-unique CB (recv)\n",
session);
memcpy (session->internals.cb_tls_unique, data, data_size);
session->internals.cb_tls_unique_len = data_size;
}
session->internals.initial_negotiation_completed = 1;
cleanup:
_gnutls_buffer_clear(&buf);
return ret;
}
|
↓
|
_gnutls_cert_type_recv_params
|
12
|
38
|
91
|
ext/cert_type.c
|
static int
_gnutls_cert_type_recv_params (gnutls_session_t session,
const opaque * data, size_t _data_size)
{
int new_type = -1, ret, i;
ssize_t data_size = _data_size;
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
if (data_size > 0)
{
if (data_size != 1)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
new_type = _gnutls_num2cert_type (data[0]);
if (new_type < 0)
{
gnutls_assert ();
return new_type;
}
/* Check if we support this cert_type */
if ((ret =
_gnutls_session_cert_type_supported (session, new_type)) < 0)
{
gnutls_assert ();
return ret;
}
_gnutls_session_cert_type_set (session, new_type);
}
}
else
{ /* SERVER SIDE - we must check if the sent cert type is the right one
*/
if (data_size > 1)
{
uint8_t len;
DECR_LEN (data_size, 1);
len = data[0];
DECR_LEN (data_size, len);
for (i = 0; i < len; i++)
{
new_type = _gnutls_num2cert_type (data[i + 1]);
if (new_type < 0)
continue;
/* Check if we support this cert_type */
if ((ret =
_gnutls_session_cert_type_supported (session,
new_type)) < 0)
{
gnutls_assert ();
continue;
}
else
break;
/* new_type is ok */
}
if (new_type < 0)
{
gnutls_assert ();
return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
if ((ret =
_gnutls_session_cert_type_supported (session, new_type)) < 0)
{
gnutls_assert ();
/* The peer has requested unsupported certificate
* types. Instead of failing, procceed normally.
* (the ciphersuite selection would fail, or a
* non certificate ciphersuite will be selected).
*/
return 0;
}
_gnutls_session_cert_type_set (session, new_type);
}
}
return 0;
}
|
↓
|
retrieve_pin_for_pinfile
|
12
|
38
|
63
|
pkcs11.c
|
static int
retrieve_pin_for_pinfile (const char *pinfile, struct ck_token_info *token_info,
int attempts, ck_user_type_t user_type, struct p11_kit_pin **pin)
{
unsigned int flags = 0;
struct p11_kit_uri *token_uri;
struct p11_kit_pin *result;
char *label;
label = p11_kit_space_strdup (token_info->label, sizeof (token_info->label));
if (label == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
token_uri = p11_kit_uri_new ();
if (token_uri == NULL)
{
free (label);
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
memcpy (p11_kit_uri_get_token_info (token_uri), token_info,
sizeof (struct ck_token_info));
if (attempts)
flags |= P11_KIT_PIN_FLAGS_RETRY;
if (user_type == CKU_USER)
{
flags |= P11_KIT_PIN_FLAGS_USER_LOGIN;
if (token_info->flags & CKF_USER_PIN_COUNT_LOW)
flags |= P11_KIT_PIN_FLAGS_MANY_TRIES;
if (token_info->flags & CKF_USER_PIN_FINAL_TRY)
flags |= P11_KIT_PIN_FLAGS_FINAL_TRY;
}
else if (user_type == CKU_SO)
{
flags |= P11_KIT_PIN_FLAGS_SO_LOGIN;
if (token_info->flags & CKF_SO_PIN_COUNT_LOW)
flags |= P11_KIT_PIN_FLAGS_MANY_TRIES;
if (token_info->flags & CKF_SO_PIN_FINAL_TRY)
flags |= P11_KIT_PIN_FLAGS_FINAL_TRY;
}
else if (user_type == CKU_CONTEXT_SPECIFIC)
{
flags |= P11_KIT_PIN_FLAGS_CONTEXT_LOGIN;
}
result = p11_kit_pin_request (pinfile, token_uri, label, flags);
p11_kit_uri_free (token_uri);
free (label);
if (result == NULL)
{
gnutls_assert ();
return GNUTLS_E_PKCS11_PIN_ERROR;
}
*pin = result;
return 0;
}
|
↓
|
stream_filter_read
|
12
|
36
|
64
|
opencdk/stream.c
|
static cdk_error_t
stream_filter_read (cdk_stream_t s)
{
struct stream_filter_s *f;
cdk_error_t rc = 0;
assert (s);
if (s->flags.filtrated)
return 0;
for (f = s->filters; f; f = f->next)
{
if (!f->flags.enabled)
continue;
if (f->flags.error)
{
_gnutls_read_log ("filter %s [read]: has the error flag; skipped\n",
s->fname ? s->fname : "[temp]");
continue;
}
f->tmp = _cdk_tmpfile ();
if (!f->tmp)
{
rc = CDK_File_Error;
break;
}
rc = f->fnct (f->opaque, f->ctl, s->fp, f->tmp);
_gnutls_read_log ("filter %s [read]: type=%d rc=%d\n",
s->fname ? s->fname : "[temp]", f->type, rc);
if (rc)
{
f->flags.error = 1;
break;
}
f->flags.error = 0;
/* If the filter is read-only, do not replace the FP because
the contents were not altered in any way. */
if (!f->flags.rdonly)
{
rc = stream_fp_replace (s, &f->tmp);
if (rc)
break;
}
else
{
fclose (f->tmp);
f->tmp = NULL;
}
rc = cdk_stream_seek (s, 0);
if (rc)
break;
/* Disable the filter after it was successfully used. The idea
is the following: let's say the armor filter was pushed and
later more filters were added. The second time the filter code
will be executed, only the new filter should be started but
not the old because we already used it. */
f->flags.enabled = 0;
}
return rc;
}
|
↓
|
gnutls_x509_crt_get_authority_key_id
|
12
|
36
|
73
|
x509/x509.c
|
int
gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert, void *ret,
size_t * ret_size,
unsigned int *critical)
{
int result, len;
gnutls_datum_t id;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (ret)
memset (ret, 0, *ret_size);
else
*ret_size = 0;
if ((result =
_gnutls_x509_crt_get_extension (cert, "2.5.29.35", 0, &id,
critical)) < 0)
{
return result;
}
if (id.size == 0 || id.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.AuthorityKeyIdentifier", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_free_datum (&id);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, id.data, id.size, NULL);
_gnutls_free_datum (&id);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
len = *ret_size;
result = asn1_read_value (c2, "keyIdentifier", ret, &len);
*ret_size = len;
asn1_delete_structure (&c2);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (result != ASN1_SUCCESS)
{
if (result != ASN1_MEM_ERROR)
gnutls_assert ();
return _gnutls_asn2err (result);
}
return 0;
}
|
↓
|
gnutls_x509_crt_get_subject_key_id
|
12
|
36
|
72
|
x509/x509.c
|
int
gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert, void *ret,
size_t * ret_size, unsigned int *critical)
{
int result, len;
gnutls_datum_t id;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (ret)
memset (ret, 0, *ret_size);
else
*ret_size = 0;
if ((result =
_gnutls_x509_crt_get_extension (cert, "2.5.29.14", 0, &id,
critical)) < 0)
{
return result;
}
if (id.size == 0 || id.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.SubjectKeyIdentifier", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_free_datum (&id);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, id.data, id.size, NULL);
_gnutls_free_datum (&id);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
len = *ret_size;
result = asn1_read_value (c2, "", ret, &len);
*ret_size = len;
asn1_delete_structure (&c2);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (result != ASN1_SUCCESS)
{
if (result != ASN1_MEM_ERROR)
gnutls_assert ();
return _gnutls_asn2err (result);
}
return 0;
}
|
↓
|
_gnutls_sr_recv_params
|
12
|
36
|
76
|
ext/safe_renegotiation.c
|
static int
_gnutls_sr_recv_params (gnutls_session_t session,
const opaque * data, size_t _data_size)
{
int len = data[0];
ssize_t data_size = _data_size;
sr_ext_st *priv;
extension_priv_data_t epriv;
int set = 0, ret;
DECR_LEN (data_size, len + 1 /* count the first byte and payload */ );
if (session->internals.priorities.sr == SR_DISABLED)
{
gnutls_assert ();
return 0;
}
ret = _gnutls_ext_get_session_data (session,
GNUTLS_EXTENSION_SAFE_RENEGOTIATION,
&epriv);
if (ret < 0 && session->security_parameters.entity == GNUTLS_SERVER)
{
set = 1;
}
else if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (set != 0)
{
priv = gnutls_calloc (1, sizeof (*priv));
if (priv == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
epriv.ptr = priv;
}
else
priv = epriv.ptr;
/* It is not legal to receive this extension on a renegotiation and
* not receive it on the initial negotiation.
*/
if (session->internals.initial_negotiation_completed != 0 &&
priv->connection_using_safe_renegotiation == 0)
{
gnutls_assert ();
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
if (len > sizeof (priv->ri_extension_data))
{
gnutls_assert ();
return GNUTLS_E_SAFE_RENEGOTIATION_FAILED;
}
if (len > 0)
memcpy (priv->ri_extension_data, &data[1], len);
priv->ri_extension_data_len = len;
/* "safe renegotiation received" means on *this* handshake; "connection using
* safe renegotiation" means that the initial hello received on the connection
* indicated safe renegotiation.
*/
priv->safe_renegotiation_received = 1;
priv->connection_using_safe_renegotiation = 1;
if (set != 0)
_gnutls_ext_set_session_data (session,
GNUTLS_EXTENSION_SAFE_RENEGOTIATION, epriv);
return 0;
}
|
↓
|
ecc_projective_check_point
|
12
|
35
|
72
|
nettle/ecc_projective_check_point.c
|
int ecc_projective_check_point (ecc_point * P, mpz_t b, mpz_t modulus)
{
mpz_t t1, t2, t3;
int err;
if (P == NULL || b == NULL || modulus == NULL)
return -1;
if (mpz_cmp_ui (P->z, 1) != 0)
{
gnutls_assert ();
return -1;
}
if ((err = mp_init_multi (&t1, &t2, &t3, NULL)) != 0)
{
return err;
}
/* t1 = Z * Z */
mpz_mul (t1, P->y, P->y);
mpz_mod (t1, t1, modulus); /* t1 = y^2 */
mpz_mul (t2, P->x, P->x);
mpz_mod (t2, t2, modulus);
mpz_mul (t2, P->x, t2);
mpz_mod (t2, t2, modulus); /* t2 = x^3 */
mpz_add (t3, P->x, P->x);
if (mpz_cmp (t3, modulus) >= 0)
{
mpz_sub (t3, t3, modulus);
}
mpz_add (t3, t3, P->x); /* t3 = 3x */
if (mpz_cmp (t3, modulus) >= 0)
{
mpz_sub (t3, t3, modulus);
}
mpz_sub (t1, t1, t2); /* t1 = y^2 - x^3 */
if (mpz_cmp_ui (t1, 0) < 0)
{
mpz_add (t1, t1, modulus);
}
mpz_add (t1, t1, t3); /* t1 = y^2 - x^3 + 3x */
if (mpz_cmp (t1, modulus) >= 0)
{
mpz_sub (t1, t1, modulus);
}
mpz_sub (t1, t1, b); /* t1 = y^2 - x^3 + 3x - b */
if (mpz_cmp_ui (t1, 0) < 0)
{
mpz_add (t1, t1, modulus);
}
if (mpz_cmp_ui (t1, 0) != 0)
{
err = -1;
}
else
{
err = 0;
}
mp_clear_multi(&t1, &t2, &t3, NULL);
return err;
}
|
↓
|
cdk_listkey_next
|
12
|
35
|
55
|
opencdk/keydb.c
|
cdk_error_t
cdk_listkey_next (cdk_listkey_t ctx, cdk_kbnode_t * ret_key)
{
if (!ctx || !ret_key)
{
gnutls_assert ();
return CDK_Inv_Value;
}
if (!ctx->init)
{
gnutls_assert ();
return CDK_Inv_Mode;
}
if (ctx->type && ctx->u.patt[0] == '*')
return cdk_keydb_get_keyblock (ctx->inp, ret_key);
else if (ctx->type)
{
cdk_kbnode_t node;
struct cdk_keydb_search_s ks;
cdk_error_t rc;
for (;;)
{
rc = cdk_keydb_get_keyblock (ctx->inp, &node);
if (rc)
{
gnutls_assert ();
return rc;
}
memset (&ks, 0, sizeof (ks));
ks.type = CDK_DBSEARCH_SUBSTR;
ks.u.pattern = ctx->u.patt;
if (find_by_pattern (node, &ks))
{
*ret_key = node;
return 0;
}
cdk_kbnode_release (node);
node = NULL;
}
}
else
{
if (!ctx->t)
ctx->t = ctx->u.fpatt;
else if (ctx->t->next)
ctx->t = ctx->t->next;
else
return CDK_EOF;
return cdk_keydb_get_bypattern (ctx->db, ctx->t->d, ret_key);
}
gnutls_assert ();
return CDK_General_Error;
}
|
↓
|
gnutls_openpgp_crt_get_auth_subkey
|
12
|
35
|
65
|
openpgp/pgp.c
|
int
gnutls_openpgp_crt_get_auth_subkey (gnutls_openpgp_crt_t crt,
gnutls_openpgp_keyid_t keyid,
unsigned int flag)
{
int ret, subkeys, i;
unsigned int usage;
unsigned int keyid_init = 0;
subkeys = gnutls_openpgp_crt_get_subkey_count (crt);
if (subkeys <= 0)
{
gnutls_assert ();
return GNUTLS_E_OPENPGP_SUBKEY_ERROR;
}
/* Try to find a subkey with the authentication flag set.
* if none exists use the last one found
*/
for (i = 0; i < subkeys; i++)
{
ret = gnutls_openpgp_crt_get_subkey_pk_algorithm(crt, i, NULL);
if (ret == GNUTLS_PK_UNKNOWN)
continue;
ret = gnutls_openpgp_crt_get_subkey_revoked_status (crt, i);
if (ret != 0) /* it is revoked. ignore it */
continue;
if (keyid_init == 0)
{ /* keep the first valid subkey */
ret = gnutls_openpgp_crt_get_subkey_id (crt, i, keyid);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
keyid_init = 1;
}
ret = gnutls_openpgp_crt_get_subkey_usage (crt, i, &usage);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
if (usage & GNUTLS_KEY_KEY_AGREEMENT)
{
ret = gnutls_openpgp_crt_get_subkey_id (crt, i, keyid);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
return 0;
}
}
if (flag && keyid_init)
return 0;
else
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
|
↓
|
cdk_pk_check_self_sig
|
12
|
34
|
61
|
opencdk/sig-check.c
|
cdk_error_t
cdk_pk_check_self_sig (cdk_kbnode_t key, int *r_status)
{
cdk_pkt_signature_t sig;
cdk_kbnode_t node;
cdk_error_t rc;
u32 keyid[2], sigid[2];
int is_selfsig, sig_ok;
cdk_kbnode_t p, ctx = NULL;
cdk_packet_t pkt;
if (!key || !r_status)
return CDK_Inv_Value;
cdk_pk_get_keyid (key->pkt->pkt.public_key, keyid);
while ((p = cdk_kbnode_walk (key, &ctx, 0)))
{
pkt = cdk_kbnode_get_packet (p);
if (pkt->pkttype != CDK_PKT_PUBLIC_SUBKEY
&& pkt->pkttype != CDK_PKT_PUBLIC_KEY)
continue;
/* FIXME: we should set expire/revoke here also but callers
expect CDK_KEY_VALID=0 if the key is okay. */
sig_ok = 0;
for (node = p; node; node = node->next)
{
if (node->pkt->pkttype != CDK_PKT_SIGNATURE)
continue;
sig = node->pkt->pkt.signature;
cdk_sig_get_keyid (sig, sigid);
if (sigid[0] != keyid[0] || sigid[1] != keyid[1])
continue;
/* FIXME: Now we check all self signatures. */
rc = _cdk_pk_check_sig (NULL, p, node, &is_selfsig, NULL);
if (rc)
{
*r_status = CDK_KEY_INVALID;
return rc;
}
else /* For each valid self sig we increase this counter. */
sig_ok++;
}
/* A key without a self signature is not valid. At least one
* signature for the given key has to be found.
*/
if (!sig_ok)
{
*r_status = CDK_KEY_INVALID;
return CDK_General_Error;
}
}
/* No flags indicate a valid key. */
*r_status = CDK_KEY_VALID;
return 0;
}
|
↓
|
_gnutls_sr_send_params
|
12
|
34
|
74
|
ext/safe_renegotiation.c
|
static int
_gnutls_sr_send_params (gnutls_session_t session, gnutls_buffer_st* extdata)
{
/* The format of this extension is a one-byte length of verify data followed
* by the verify data itself. Note that the length byte does not include
* itself; IOW, empty verify data is represented as a length of 0. That means
* the minimum extension is one byte: 0x00.
*/
sr_ext_st *priv;
int ret, set = 0, len;
extension_priv_data_t epriv;
size_t init_length = extdata->length;
if (session->internals.priorities.sr == SR_DISABLED)
{
gnutls_assert ();
return 0;
}
ret = _gnutls_ext_get_session_data (session,
GNUTLS_EXTENSION_SAFE_RENEGOTIATION,
&epriv);
if (ret < 0)
{
set = 1;
}
if (set != 0)
{
priv = gnutls_calloc (1, sizeof (*priv));
if (priv == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
epriv.ptr = priv;
_gnutls_ext_set_session_data (session,
GNUTLS_EXTENSION_SAFE_RENEGOTIATION,
epriv);
}
else
priv = epriv.ptr;
/* Always offer the extension if we're a client */
if (priv->connection_using_safe_renegotiation ||
session->security_parameters.entity == GNUTLS_CLIENT)
{
len = priv->client_verify_data_len;
if (session->security_parameters.entity == GNUTLS_SERVER)
len += priv->server_verify_data_len;
ret = _gnutls_buffer_append_prefix(extdata, 8, len);
if (ret < 0)
return gnutls_assert_val(ret);
ret = _gnutls_buffer_append_data(extdata, priv->client_verify_data,
priv->client_verify_data_len);
if (ret < 0)
return gnutls_assert_val(ret);
if (session->security_parameters.entity == GNUTLS_SERVER)
{
ret = _gnutls_buffer_append_data(extdata, priv->server_verify_data,
priv->server_verify_data_len);
if (ret < 0)
return gnutls_assert_val(ret);
}
}
else
return 0;
return extdata->length - init_length;
}
|
↓
|
gnutls_openpgp_crt_verify_ring
|
12
|
33
|
58
|
openpgp/pgpverify.c
|
int
gnutls_openpgp_crt_verify_ring (gnutls_openpgp_crt_t key,
gnutls_openpgp_keyring_t keyring,
unsigned int flags, unsigned int *verify)
{
uint8_t id[GNUTLS_OPENPGP_KEYID_SIZE];
cdk_error_t rc;
int status;
if (!key || !keyring)
{
gnutls_assert ();
return GNUTLS_E_NO_CERTIFICATE_FOUND;
}
*verify = 0;
rc = cdk_pk_check_sigs (key->knode, keyring->db, &status);
if (rc == CDK_Error_No_Key)
{
rc = GNUTLS_E_NO_CERTIFICATE_FOUND;
gnutls_assert ();
return rc;
}
else if (rc != CDK_Success)
{
_gnutls_debug_log ("cdk_pk_check_sigs: error %d\n", rc);
rc = _gnutls_map_cdk_rc (rc);
gnutls_assert ();
return rc;
}
_gnutls_debug_log ("status: %x\n", status);
if (status & CDK_KEY_INVALID)
*verify |= GNUTLS_CERT_INVALID;
if (status & CDK_KEY_REVOKED)
*verify |= GNUTLS_CERT_REVOKED;
if (status & CDK_KEY_NOSIGNER)
*verify |= GNUTLS_CERT_SIGNER_NOT_FOUND;
/* Check if the key is included in the ring. */
if (!(flags & GNUTLS_VERIFY_DO_NOT_ALLOW_SAME))
{
rc = gnutls_openpgp_crt_get_key_id (key, id);
if (rc < 0)
{
gnutls_assert ();
return rc;
}
rc = gnutls_openpgp_keyring_check_id (keyring, id, 0);
/* If it exists in the keyring don't treat it as unknown. */
if (rc == 0 && *verify & GNUTLS_CERT_SIGNER_NOT_FOUND)
*verify ^= GNUTLS_CERT_SIGNER_NOT_FOUND;
}
return 0;
}
|
↓
|
write_literal
|
12
|
31
|
47
|
opencdk/write-packet.c
|
static cdk_error_t
write_literal (cdk_stream_t out, cdk_pkt_literal_t pt, int old_ctb)
{
byte buf[BUFSIZE];
size_t size;
cdk_error_t rc;
assert (out);
assert (pt);
/* We consider a packet without a body as an invalid packet.
At least one octet must be present. */
if (!pt->len)
return CDK_Inv_Packet;
if (DEBUG_PKT)
_gnutls_write_log ("write_literal:\n");
size = 6 + pt->namelen + pt->len;
rc = pkt_write_head (out, old_ctb, size, CDK_PKT_LITERAL);
if (rc)
return rc;
rc = stream_putc (out, pt->mode);
if (rc)
return rc;
rc = stream_putc (out, pt->namelen);
if (rc)
return rc;
if (pt->namelen > 0)
rc = stream_write (out, pt->name, pt->namelen);
if (!rc)
rc = write_32 (out, pt->timestamp);
if (rc)
return rc;
while (!cdk_stream_eof (pt->buf) && !rc)
{
rc = stream_read (pt->buf, buf, DIM (buf), &size);
if (!rc)
rc = stream_write (out, buf, size);
}
memset (buf, 0, sizeof (buf));
return rc;
}
|
↓
|
gnutls_dtls_cookie_verify
|
12
|
31
|
56
|
gnutls_dtls.c
|
int gnutls_dtls_cookie_verify(gnutls_datum_t* key,
void* client_data, size_t client_data_size,
void* _msg, size_t msg_size, gnutls_dtls_prestate_st* prestate)
{
gnutls_datum_t cookie;
int sid_size;
int pos, ret;
uint8_t * msg = _msg;
uint8_t digest[C_HASH_SIZE];
if (key == NULL || key->data == NULL || key->size == 0)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
/* format:
* version - 2 bytes
* random - 32 bytes
* session_id - 1 byte length + content
* cookie - 1 byte length + content
*/
pos = 34+DTLS_RECORD_HEADER_SIZE+DTLS_HANDSHAKE_HEADER_SIZE;
if (msg_size < pos+1)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
sid_size = msg[pos++];
if (sid_size > 32 || msg_size < pos+sid_size+1)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
pos += sid_size;
cookie.size = msg[pos++];
if (msg_size < pos+cookie.size+1)
return gnutls_assert_val(GNUTLS_E_UNEXPECTED_PACKET_LENGTH);
cookie.data = &msg[pos];
if (cookie.size != COOKIE_SIZE)
{
if (cookie.size > 0) _gnutls_audit_log(NULL, "Received cookie with illegal size %d. Expected %d\n", (int)cookie.size, COOKIE_SIZE);
return gnutls_assert_val(GNUTLS_E_BAD_COOKIE);
}
ret = _gnutls_hmac_fast(C_HASH, key->data, key->size, client_data, client_data_size, digest);
if (ret < 0)
return gnutls_assert_val(ret);
if (memcmp(digest, cookie.data, COOKIE_MAC_SIZE) != 0)
return gnutls_assert_val(GNUTLS_E_BAD_COOKIE);
prestate->record_seq = msg[10]; /* client's record seq */
prestate->hsk_read_seq = msg[DTLS_RECORD_HEADER_SIZE+5]; /* client's hsk seq */
prestate->hsk_write_seq = 0;/* we always send zero for this msg */
return 0;
}
|
↓
|
print_aia
|
12
|
31
|
56
|
x509/output.c
|
static void
print_aia (gnutls_buffer_st * str, gnutls_x509_crt_t cert)
{
int err;
int seq = 0;
gnutls_datum_t data;
for (;;)
{
err = gnutls_x509_crt_get_authority_info_access
(cert, seq, GNUTLS_IA_ACCESSMETHOD_OID, &data, NULL);
if (err == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
return;
if (err < 0)
{
addf (str, "error: get_aia: %s\n", gnutls_strerror (err));
return;
}
addf (str, _("\t\t\tAccess Method: %.*s"), data.size, data.data);
if (data.size == sizeof (GNUTLS_OID_AD_OCSP) &&
memcmp (data.data, GNUTLS_OID_AD_OCSP, data.size) == 0)
adds (str, " (id-ad-ocsp)\n");
else if (data.size == sizeof (GNUTLS_OID_AD_CAISSUERS) &&
memcmp (data.data, GNUTLS_OID_AD_CAISSUERS, data.size) == 0)
adds (str, " (id-ad-caIssuers)\n");
else
adds (str, " (UNKNOWN)\n");
err = gnutls_x509_crt_get_authority_info_access
(cert, seq, GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE, &data, NULL);
if (err < 0)
{
addf (str, "error: get_aia type: %s\n", gnutls_strerror (err));
return;
}
if (data.size == sizeof ("uniformResourceIdentifier") &&
memcmp (data.data, "uniformResourceIdentifier", data.size) == 0)
{
adds (str, "\t\t\tAccess Location URI: ");
err = gnutls_x509_crt_get_authority_info_access
(cert, seq, GNUTLS_IA_URI, &data, NULL);
if (err < 0)
{
addf (str, "error: get_aia uri: %s\n", gnutls_strerror (err));
return;
}
addf (str, "%.*s\n", data.size, data.data);
}
else
adds (str, "\t\t\tUnsupported accessLocation type\n");
seq++;
}
}
|
↓
|
read_pubkey_enc
|
12
|
25
|
33
|
opencdk/read-packet.c
|
static cdk_error_t
read_pubkey_enc (cdk_stream_t inp, size_t pktlen, cdk_pkt_pubkey_enc_t pke)
{
size_t i, nenc;
if (!inp || !pke)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_pubkey_enc: %d octets\n", (int) pktlen);
if (pktlen < 12)
return CDK_Inv_Packet;
pke->version = cdk_stream_getc (inp);
if (pke->version < 2 || pke->version > 3)
return CDK_Inv_Packet;
pke->keyid[0] = read_32 (inp);
pke->keyid[1] = read_32 (inp);
if (!pke->keyid[0] && !pke->keyid[1])
pke->throw_keyid = 1; /* RFC2440 "speculative" keyID */
pke->pubkey_algo = _pgp_pub_algo_to_cdk (cdk_stream_getc (inp));
nenc = cdk_pk_get_nenc (pke->pubkey_algo);
if (!nenc)
return CDK_Inv_Algo;
for (i = 0; i < nenc; i++)
{
cdk_error_t rc = read_mpi (inp, &pke->mpi[i], 0);
if (rc)
return rc;
}
return 0;
}
|
↓
|
session_ticket_send_params
|
12
|
24
|
52
|
ext/session_ticket.c
|
static int
session_ticket_send_params (gnutls_session_t session,
gnutls_buffer_st * extdata)
{
session_ticket_ext_st *priv = NULL;
extension_priv_data_t epriv;
int ret;
ret =
_gnutls_ext_get_session_data (session, GNUTLS_EXTENSION_SESSION_TICKET,
&epriv);
if (ret >= 0)
priv = epriv.ptr;
if (priv == NULL || !priv->session_ticket_enable)
return 0;
if (session->security_parameters.entity == GNUTLS_SERVER)
{
if (priv && priv->session_ticket_renew)
{
return GNUTLS_E_INT_RET_0;
}
}
else
{
ret =
_gnutls_ext_get_resumed_session_data (session,
GNUTLS_EXTENSION_SESSION_TICKET,
&epriv);
if (ret >= 0)
priv = epriv.ptr;
/* no previous data. Just advertize it */
if (ret < 0)
return GNUTLS_E_INT_RET_0;
/* previous data had session tickets disabled. Don't advertize. Ignore. */
if (!priv->session_ticket_enable)
return 0;
if (priv->session_ticket_len > 0)
{
ret = _gnutls_buffer_append_data( extdata, priv->session_ticket, priv->session_ticket_len);
if (ret < 0)
return gnutls_assert_val(ret);
return priv->session_ticket_len;
}
}
return 0;
}
|
↓
|
_gnutls_session_cert_type_supported
|
12
|
24
|
49
|
gnutls_state.c
|
int
_gnutls_session_cert_type_supported (gnutls_session_t session,
gnutls_certificate_type_t cert_type)
{
unsigned i;
unsigned cert_found = 0;
gnutls_certificate_credentials_t cred;
if (session->security_parameters.entity == GNUTLS_SERVER)
{
cred = (gnutls_certificate_credentials_t)
_gnutls_get_cred (session->key, GNUTLS_CRD_CERTIFICATE, NULL);
if (cred == NULL)
return GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;
if (cred->server_get_cert_callback == NULL
&& cred->get_cert_callback == NULL)
{
for (i = 0; i < cred->ncerts; i++)
{
if (cred->certs[i].cert_list[0].type == cert_type)
{
cert_found = 1;
break;
}
}
if (cert_found == 0)
/* no certificate is of that type.
*/
return GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;
}
}
if (session->internals.priorities.cert_type.algorithms == 0
&& cert_type == DEFAULT_CERT_TYPE)
return 0;
for (i = 0; i < session->internals.priorities.cert_type.algorithms; i++)
{
if (session->internals.priorities.cert_type.priority[i] == cert_type)
{
return 0; /* ok */
}
}
return GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;
}
|
↓
|
_gnutls_hostname_compare
|
12
|
19
|
42
|
gnutls_str.c
|
int
_gnutls_hostname_compare (const char *certname,
size_t certnamesize, const char *hostname, int level)
{
if (level > 5)
return 0;
/* find the first different character */
for (; *certname && *hostname && c_toupper (*certname) == c_toupper (*hostname);
certname++, hostname++, certnamesize--)
;
/* the strings are the same */
if (certnamesize == 0 && *hostname == '\0')
return 1;
if (*certname == '*')
{
/* a wildcard certificate */
certname++;
certnamesize--;
while (1)
{
/* Use a recursive call to allow multiple wildcards */
if (_gnutls_hostname_compare (certname, certnamesize, hostname, level+1))
return 1;
/* wildcards are only allowed to match a single domain
component or component fragment */
if (*hostname == '\0' || *hostname == '.')
break;
hostname++;
}
return 0;
}
return 0;
}
|
↓
|
_gnutls_handshake_server
|
11
|
46
|
100
|
gnutls_handshake.c
|
int
_gnutls_handshake_server (gnutls_session_t session)
{
int ret = 0;
switch (STATE)
{
case STATE0:
case STATE1:
ret =
_gnutls_recv_handshake (session,
GNUTLS_HANDSHAKE_CLIENT_HELLO,
MANDATORY_PACKET, NULL);
STATE = STATE1;
IMED_RET ("recv hello", ret, 1);
case STATE2:
ret = _gnutls_send_hello (session, AGAIN (STATE2));
STATE = STATE2;
IMED_RET ("send hello", ret, 1);
case STATE70:
if (session->security_parameters.do_send_supplemental)
{
ret = _gnutls_send_supplemental (session, AGAIN (STATE70));
STATE = STATE70;
IMED_RET ("send supplemental data", ret, 0);
}
/* SEND CERTIFICATE + KEYEXCHANGE + CERTIFICATE_REQUEST */
case STATE3:
/* NOTE: these should not be send if we are resuming */
if (session->internals.resumed == RESUME_FALSE)
ret = _gnutls_send_server_certificate (session, AGAIN (STATE3));
STATE = STATE3;
IMED_RET ("send server certificate", ret, 0);
case STATE4:
/* send server key exchange (A) */
if (session->internals.resumed == RESUME_FALSE)
ret = _gnutls_send_server_kx_message (session, AGAIN (STATE4));
STATE = STATE4;
IMED_RET ("send server kx", ret, 0);
case STATE5:
/* Send certificate request - if requested to */
if (session->internals.resumed == RESUME_FALSE)
ret =
_gnutls_send_server_certificate_request (session, AGAIN (STATE5));
STATE = STATE5;
IMED_RET ("send server cert request", ret, 0);
case STATE6:
/* send the server hello done */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret =
_gnutls_send_empty_handshake (session,
GNUTLS_HANDSHAKE_SERVER_HELLO_DONE,
AGAIN (STATE6));
STATE = STATE6;
IMED_RET ("send server hello done", ret, 1);
case STATE71:
if (session->security_parameters.do_recv_supplemental)
{
ret = _gnutls_recv_supplemental (session);
STATE = STATE71;
IMED_RET ("recv client supplemental", ret, 1);
}
/* RECV CERTIFICATE + KEYEXCHANGE + CERTIFICATE_VERIFY */
case STATE7:
/* receive the client certificate message */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_client_certificate (session);
STATE = STATE7;
IMED_RET ("recv client certificate", ret, 1);
case STATE8:
/* receive the client key exchange message */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_client_kx_message (session);
STATE = STATE8;
IMED_RET ("recv client kx", ret, 1);
case STATE9:
/* receive the client certificate verify message */
if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */
ret = _gnutls_recv_client_certificate_verify_message (session);
STATE = STATE9;
IMED_RET ("recv client certificate verify", ret, 1);
STATE = STATE0; /* finished thus clear session */
default:
break;
}
return 0;
}
|
↓
|
pkcs11_get_info
|
11
|
68
|
116
|
pkcs11.c
|
int
pkcs11_get_info (struct p11_kit_uri *info,
gnutls_pkcs11_obj_info_t itype, void *output,
size_t * output_size)
{
struct ck_attribute *attr = NULL;
struct ck_version *version = NULL;
const char *str = NULL;
size_t str_max = 0;
int terminate = 0;
int hexify = 0;
size_t length = 0;
const char *data = NULL;
char buf[32];
/*
* Either attr, str or version is valid by the time switch
* finishes
*/
switch (itype)
{
case GNUTLS_PKCS11_OBJ_ID:
attr = p11_kit_uri_get_attribute (info, CKA_ID);
break;
case GNUTLS_PKCS11_OBJ_ID_HEX:
attr = p11_kit_uri_get_attribute (info, CKA_ID);
hexify = 1;
terminate = 1;
break;
case GNUTLS_PKCS11_OBJ_LABEL:
attr = p11_kit_uri_get_attribute (info, CKA_LABEL);
terminate = 1;
break;
case GNUTLS_PKCS11_OBJ_TOKEN_LABEL:
str = p11_kit_uri_get_token_info (info)->label;
str_max = 32;
break;
case GNUTLS_PKCS11_OBJ_TOKEN_SERIAL:
str = p11_kit_uri_get_token_info (info)->serial_number;
str_max = 16;
break;
case GNUTLS_PKCS11_OBJ_TOKEN_MANUFACTURER:
str = p11_kit_uri_get_token_info (info)->manufacturer_id;
str_max = 32;
break;
case GNUTLS_PKCS11_OBJ_TOKEN_MODEL:
str = p11_kit_uri_get_token_info (info)->model;
str_max = 16;
break;
case GNUTLS_PKCS11_OBJ_LIBRARY_DESCRIPTION:
str = p11_kit_uri_get_module_info (info)->library_description;
str_max = 32;
break;
case GNUTLS_PKCS11_OBJ_LIBRARY_VERSION:
version = &p11_kit_uri_get_module_info (info)->library_version;
break;
case GNUTLS_PKCS11_OBJ_LIBRARY_MANUFACTURER:
str = p11_kit_uri_get_module_info (info)->manufacturer_id;
str_max = 32;
break;
default:
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (attr != NULL)
{
data = attr->value;
length = attr->value_len;
}
else if (str != NULL)
{
data = str;
length = p11_kit_space_strlen (str, str_max);
terminate = 1;
}
else if (version != NULL)
{
data = buf;
length = snprintf (buf, sizeof (buf), "%d.%d", (int)version->major,
(int)version->minor);
terminate = 1;
}
if (hexify)
{
/* terminate is assumed with hexify */
if (*output_size < length * 3)
{
*output_size = length * 3;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
if (output)
_gnutls_bin2hex (data, length, output, *output_size, ":");
*output_size = length * 3;
return 0;
}
else
{
if (*output_size < length + terminate)
{
*output_size = length + terminate;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
if (output)
{
memcpy (output, data, length);
if (terminate)
((unsigned char*)output)[length] = '\0';
}
*output_size = length + terminate;
}
return 0;
}
|
↓
|
_wrap_nettle_pk_sign
|
11
|
75
|
150
|
nettle/pk.c
|
static int
_wrap_nettle_pk_sign (gnutls_pk_algorithm_t algo,
gnutls_datum_t * signature,
const gnutls_datum_t * vdata,
const gnutls_pk_params_st * pk_params)
{
int ret, hash;
switch (algo)
{
case GNUTLS_PK_EC: /* we do ECDSA */
{
ecc_key priv;
struct dsa_signature sig;
int hash_len;
_ecc_params_to_privkey(pk_params, &priv);
dsa_signature_init (&sig);
hash = _gnutls_dsa_q_to_hash (algo, pk_params, &hash_len);
if (hash_len > vdata->size)
{
gnutls_assert ();
_gnutls_debug_log("Security level of algorithm requires hash %s(%d) or better\n", gnutls_mac_get_name(hash), hash_len);
hash_len = vdata->size;
}
ret = ecc_sign_hash(vdata->data, hash_len,
&sig, NULL, rnd_func, &priv);
if (ret != 0)
{
gnutls_assert ();
ret = GNUTLS_E_PK_SIGN_FAILED;
goto ecdsa_fail;
}
ret = _gnutls_encode_ber_rs (signature, &sig.r, &sig.s);
ecdsa_fail:
dsa_signature_clear (&sig);
_ecc_params_clear( &priv);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
}
case GNUTLS_PK_DSA:
{
struct dsa_public_key pub;
struct dsa_private_key priv;
struct dsa_signature sig;
int hash_len;
memset(&priv, 0, sizeof(priv));
memset(&pub, 0, sizeof(pub));
_dsa_params_to_pubkey (pk_params, &pub);
_dsa_params_to_privkey (pk_params, &priv);
dsa_signature_init (&sig);
hash = _gnutls_dsa_q_to_hash (algo, pk_params, &hash_len);
if (hash_len > vdata->size)
{
gnutls_assert ();
_gnutls_debug_log("Security level of algorithm requires hash %s(%d) or better\n", gnutls_mac_get_name(hash), hash_len);
hash_len = vdata->size;
}
ret =
_dsa_sign (&pub, &priv, NULL, rnd_func,
hash_len, vdata->data, &sig);
if (ret == 0)
{
gnutls_assert ();
ret = GNUTLS_E_PK_SIGN_FAILED;
goto dsa_fail;
}
ret = _gnutls_encode_ber_rs (signature, &sig.r, &sig.s);
dsa_fail:
dsa_signature_clear (&sig);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
}
case GNUTLS_PK_RSA:
{
struct rsa_private_key priv;
bigint_t hash, nc, ri;
if (_gnutls_mpi_scan_nz (&hash, vdata->data, vdata->size) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
memset(&priv, 0, sizeof(priv));
_rsa_params_to_privkey (pk_params, &priv);
nc = rsa_blind (hash, pk_params->params[1] /*e */ ,
pk_params->params[0] /*m */ , &ri);
_gnutls_mpi_release (&hash);
if (nc == NULL)
{
gnutls_assert ();
ret = GNUTLS_E_MEMORY_ERROR;
goto rsa_fail;
}
rsa_compute_root (&priv, TOMPZ (nc), TOMPZ (nc));
rsa_unblind (nc, ri, pk_params->params[0] /*m */ );
ret = _gnutls_mpi_dprint (nc, signature);
rsa_fail:
_gnutls_mpi_release (&nc);
_gnutls_mpi_release (&ri);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
}
default:
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
|
↓
|
_wrap_nettle_pk_verify
|
11
|
62
|
112
|
nettle/pk.c
|
static int
_wrap_nettle_pk_verify (gnutls_pk_algorithm_t algo,
const gnutls_datum_t * vdata,
const gnutls_datum_t * signature,
const gnutls_pk_params_st * pk_params)
{
int ret;
int hash_len;
bigint_t tmp[2] = { NULL, NULL };
switch (algo)
{
case GNUTLS_PK_EC: /* ECDSA */
{
ecc_key pub;
struct dsa_signature sig;
int stat;
ret = _gnutls_decode_ber_rs (signature, &tmp[0], &tmp[1]);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
_ecc_params_to_pubkey(pk_params, &pub);
memcpy (&sig.r, tmp[0], sizeof (sig.r));
memcpy (&sig.s, tmp[1], sizeof (sig.s));
_gnutls_dsa_q_to_hash (algo, pk_params, &hash_len);
if (hash_len > vdata->size)
hash_len = vdata->size;
ret = ecc_verify_hash(&sig, vdata->data, hash_len, &stat, &pub);
if (ret != 0 || stat != 1)
{
gnutls_assert();
ret = GNUTLS_E_PK_SIG_VERIFY_FAILED;
}
else
ret = 0;
_gnutls_mpi_release (&tmp[0]);
_gnutls_mpi_release (&tmp[1]);
_ecc_params_clear( &pub);
break;
}
case GNUTLS_PK_DSA:
{
struct dsa_public_key pub;
struct dsa_signature sig;
ret = _gnutls_decode_ber_rs (signature, &tmp[0], &tmp[1]);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
memset(&pub, 0, sizeof(pub));
_dsa_params_to_pubkey (pk_params, &pub);
memcpy (&sig.r, tmp[0], sizeof (sig.r));
memcpy (&sig.s, tmp[1], sizeof (sig.s));
_gnutls_dsa_q_to_hash (algo, pk_params, &hash_len);
if (hash_len > vdata->size)
hash_len = vdata->size;
ret = _dsa_verify (&pub, hash_len, vdata->data, &sig);
if (ret == 0)
{
gnutls_assert();
ret = GNUTLS_E_PK_SIG_VERIFY_FAILED;
}
else
ret = 0;
_gnutls_mpi_release (&tmp[0]);
_gnutls_mpi_release (&tmp[1]);
break;
}
case GNUTLS_PK_RSA:
{
bigint_t hash;
if (_gnutls_mpi_scan_nz (&hash, vdata->data, vdata->size) != 0)
{
gnutls_assert ();
return GNUTLS_E_MPI_SCAN_FAILED;
}
ret = _gnutls_mpi_scan_nz (&tmp[0], signature->data, signature->size);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = _int_rsa_verify (pk_params, hash, tmp[0]);
_gnutls_mpi_release (&tmp[0]);
_gnutls_mpi_release (&hash);
break;
}
default:
gnutls_assert ();
ret = GNUTLS_E_INTERNAL_ERROR;
goto cleanup;
}
cleanup:
return ret;
}
|
↓
|
_pkcs12_decode_crt_bag
|
11
|
51
|
103
|
x509/pkcs12_bag.c
|
int
_pkcs12_decode_crt_bag (gnutls_pkcs12_bag_type_t type,
const gnutls_datum_t * in, gnutls_datum_t * out)
{
int ret;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
switch (type)
{
case GNUTLS_BAG_CERTIFICATE:
if ((ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-CertBag",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = asn1_der_decoding (&c2, in->data, in->size, NULL);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_read_value (c2, "certValue", out, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
case GNUTLS_BAG_CRL:
if ((ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-CRLBag",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = asn1_der_decoding (&c2, in->data, in->size, NULL);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_read_value (c2, "crlValue", out, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
case GNUTLS_BAG_SECRET:
if ((ret = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.pkcs-12-SecretBag",
&c2)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = asn1_der_decoding (&c2, in->data, in->size, NULL);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_read_value (c2, "secretValue", out, 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
break;
default:
gnutls_assert ();
asn1_delete_structure (&c2);
return GNUTLS_E_UNIMPLEMENTED_FEATURE;
}
asn1_delete_structure (&c2);
return 0;
cleanup:
asn1_delete_structure (&c2);
return ret;
}
|
↓
|
classify_data
|
11
|
23
|
41
|
opencdk/keydb.c
|
static int
classify_data (const byte * buf, size_t len)
{
int type;
unsigned int i;
if (buf[0] == '0' && (buf[1] == 'x' || buf[1] == 'X'))
{ /* Skip hex prefix. */
buf += 2;
len -= 2;
}
/* The length of the data does not match either a keyid or a fingerprint. */
if (len != 8 && len != 16 && len != 40)
return CDK_DBSEARCH_SUBSTR;
for (i = 0; i < len; i++)
{
if (!isxdigit (buf[i]))
return CDK_DBSEARCH_SUBSTR;
}
if (i != len)
return CDK_DBSEARCH_SUBSTR;
switch (len)
{
case 8:
type = CDK_DBSEARCH_SHORT_KEYID;
break;
case 16:
type = CDK_DBSEARCH_KEYID;
break;
case 40:
type = CDK_DBSEARCH_FPR;
break;
default:
type = CDK_DBSEARCH_SUBSTR;
break;
}
return type;
}
|
↓
|
gnutls_x509_crq_set_key_purpose_oid
|
11
|
52
|
110
|
x509/crq.c
|
int
gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t crq,
const void *oid, unsigned int critical)
{
int result;
gnutls_datum_t prev = { NULL, 0 }, der_data;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
size_t prev_size = 0;
/* Read existing extension, if there is one.
*/
result = gnutls_x509_crq_get_extension_by_oid (crq, "2.5.29.37", 0,
NULL, &prev_size, &critical);
prev.size = prev_size;
switch (result)
{
case GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE:
/* No existing extension, that's fine. */
break;
case GNUTLS_E_SUCCESS:
prev.data = gnutls_malloc (prev.size);
if (prev.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = gnutls_x509_crq_get_extension_by_oid (crq, "2.5.29.37", 0,
prev.data, &prev_size,
&critical);
if (result < 0)
{
gnutls_assert ();
gnutls_free (prev.data);
return result;
}
break;
default:
gnutls_assert ();
return result;
}
result = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.ExtKeyUsageSyntax", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (prev.data);
return _gnutls_asn2err (result);
}
if (prev.data)
{
/* decode it.
*/
result = asn1_der_decoding (&c2, prev.data, prev.size, NULL);
gnutls_free (prev.data);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
}
/* generate the extension.
*/
/* 1. create a new element.
*/
result = asn1_write_value (c2, "", "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
/* 2. Add the OID.
*/
result = asn1_write_value (c2, "?LAST", oid, 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
result = _gnutls_x509_der_encode (c2, "", &der_data, 0);
asn1_delete_structure (&c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
result = _gnutls_x509_crq_set_extension (crq, "2.5.29.37",
&der_data, critical);
_gnutls_free_datum (&der_data);
if (result < 0)
{
gnutls_assert ();
return result;
}
return 0;
}
|
↓
|
_gnutls_read_client_hello_v2
|
11
|
74
|
164
|
gnutls_v2_compat.c
|
int
_gnutls_read_client_hello_v2 (gnutls_session_t session, opaque * data,
int datalen)
{
uint16_t session_id_len = 0;
int pos = 0;
int ret = 0;
uint16_t sizeOfSuites;
gnutls_protocol_t adv_version;
opaque rnd[GNUTLS_RANDOM_SIZE];
int len = datalen;
int err;
uint16_t challenge;
opaque session_id[TLS_MAX_SESSION_ID_SIZE];
DECR_LEN (len, 2);
_gnutls_handshake_log
("HSK[%p]: SSL 2.0 Hello: Client's version: %d.%d\n", session,
data[pos], data[pos + 1]);
set_adv_version (session, data[pos], data[pos + 1]);
adv_version = _gnutls_version_get (data[pos], data[pos + 1]);
ret = _gnutls_negotiate_version (session, adv_version);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
pos += 2;
/* Read uint16_t cipher_spec_length */
DECR_LEN (len, 2);
sizeOfSuites = _gnutls_read_uint16 (&data[pos]);
pos += 2;
/* read session id length */
DECR_LEN (len, 2);
session_id_len = _gnutls_read_uint16 (&data[pos]);
pos += 2;
if (session_id_len > TLS_MAX_SESSION_ID_SIZE)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
/* read challenge length */
DECR_LEN (len, 2);
challenge = _gnutls_read_uint16 (&data[pos]);
pos += 2;
if (challenge < 16 || challenge > GNUTLS_RANDOM_SIZE)
{
gnutls_assert ();
return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;
}
/* call the user hello callback
*/
ret = _gnutls_user_hello_func (session, adv_version);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* find an appropriate cipher suite */
DECR_LEN (len, sizeOfSuites);
ret = _gnutls_handshake_select_v2_suite (session, &data[pos], sizeOfSuites);
pos += sizeOfSuites;
if (ret < 0)
{
gnutls_assert ();
return ret;
}
/* check if the credentials (username, public key etc.) are ok
*/
if (_gnutls_get_kx_cred
(session,
_gnutls_cipher_suite_get_kx_algo (session->
security_parameters.cipher_suite),
&err) == NULL && err != 0)
{
gnutls_assert ();
return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
}
/* set the mod_auth_st to the appropriate struct
* according to the KX algorithm. This is needed since all the
* handshake functions are read from there;
*/
session->internals.auth_struct =
_gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo
(session->
security_parameters.cipher_suite));
if (session->internals.auth_struct == NULL)
{
_gnutls_handshake_log
("HSK[%p]: SSL 2.0 Hello: Cannot find the appropriate handler for the KX algorithm\n",
session);
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
/* read random new values -skip session id for now */
DECR_LEN (len, session_id_len); /* skip session id for now */
memcpy (session_id, &data[pos], session_id_len);
pos += session_id_len;
DECR_LEN (len, challenge);
memset (rnd, 0, GNUTLS_RANDOM_SIZE);
memcpy (&rnd[GNUTLS_RANDOM_SIZE - challenge], &data[pos], challenge);
_gnutls_set_client_random (session, rnd);
/* generate server random value */
_gnutls_tls_create_random (rnd);
_gnutls_set_server_random (session, rnd);
session->security_parameters.timestamp = gnutls_time (NULL);
/* RESUME SESSION */
DECR_LEN (len, session_id_len);
ret = _gnutls_server_restore_session (session, session_id, session_id_len);
if (ret == 0)
{ /* resumed! */
/* get the new random values */
memcpy (session->internals.resumed_security_parameters.server_random,
session->security_parameters.server_random, GNUTLS_RANDOM_SIZE);
memcpy (session->internals.resumed_security_parameters.client_random,
session->security_parameters.client_random, GNUTLS_RANDOM_SIZE);
session->internals.resumed = RESUME_TRUE;
return 0;
}
else
{
_gnutls_generate_session_id (session->security_parameters.session_id,
&session->
security_parameters.session_id_size);
session->internals.resumed = RESUME_FALSE;
}
_gnutls_epoch_set_compression (session, EPOCH_NEXT, GNUTLS_COMP_NULL);
session->security_parameters.compression_method = GNUTLS_COMP_NULL;
return 0;
}
|
↓
|
_gnutls_asn1_encode_dsa
|
11
|
67
|
119
|
x509/key_encode.c
|
static int
_gnutls_asn1_encode_dsa (ASN1_TYPE * c2, gnutls_pk_params_st * params)
{
int result, i;
size_t size[DSA_PRIVATE_PARAMS], total;
opaque *p_data, *q_data, *g_data, *x_data, *y_data;
opaque *all_data = NULL, *p;
opaque null = '\0';
/* Read all the sizes */
total = 0;
for (i = 0; i < DSA_PRIVATE_PARAMS; i++)
{
_gnutls_mpi_print_lz (params->params[i], NULL, &size[i]);
total += size[i];
}
/* Encoding phase.
* allocate data enough to hold everything
*/
all_data = gnutls_malloc (total);
if (all_data == NULL)
{
gnutls_assert ();
result = GNUTLS_E_MEMORY_ERROR;
goto cleanup;
}
p = all_data;
p_data = p;
p += size[0];
q_data = p;
p += size[1];
g_data = p;
p += size[2];
y_data = p;
p += size[3];
x_data = p;
_gnutls_mpi_print_lz (params->params[0], p_data, &size[0]);
_gnutls_mpi_print_lz (params->params[1], q_data, &size[1]);
_gnutls_mpi_print_lz (params->params[2], g_data, &size[2]);
_gnutls_mpi_print_lz (params->params[3], y_data, &size[3]);
_gnutls_mpi_print_lz (params->params[4], x_data, &size[4]);
/* Ok. Now we have the data. Create the asn1 structures
*/
/* first make sure that no previously allocated data are leaked */
if (*c2 != ASN1_TYPE_EMPTY)
{
asn1_delete_structure (c2);
*c2 = ASN1_TYPE_EMPTY;
}
if ((result = asn1_create_element
(_gnutls_get_gnutls_asn (), "GNUTLS.DSAPrivateKey", c2))
!= ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Write PRIME
*/
if ((result = asn1_write_value (*c2, "p", p_data, size[0])) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "q", q_data, size[1])) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "g", g_data, size[2])) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "Y", y_data, size[3])) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
if ((result = asn1_write_value (*c2, "priv",
x_data, size[4])) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
gnutls_free (all_data);
if ((result = asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
return 0;
cleanup:
asn1_delete_structure (c2);
gnutls_free (all_data);
return result;
}
|
↓
|
_get_sk_rsa_raw
|
11
|
62
|
105
|
openpgp/privkey.c
|
static int
_get_sk_rsa_raw (gnutls_openpgp_privkey_t pkey, gnutls_openpgp_keyid_t keyid,
gnutls_datum_t * m, gnutls_datum_t * e,
gnutls_datum_t * d, gnutls_datum_t * p,
gnutls_datum_t * q, gnutls_datum_t * u)
{
int pk_algorithm, ret;
cdk_packet_t pkt;
uint32_t kid32[2];
gnutls_pk_params_st params;
if (pkey == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
KEYID_IMPORT (kid32, keyid);
pkt = _gnutls_openpgp_find_key (pkey->knode, kid32, 1);
if (pkt == NULL)
{
gnutls_assert ();
return GNUTLS_E_OPENPGP_GETKEY_FAILED;
}
pk_algorithm =
_gnutls_openpgp_get_algo (pkt->pkt.secret_key->pk->pubkey_algo);
if (pk_algorithm != GNUTLS_PK_RSA)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
ret = _gnutls_openpgp_privkey_get_mpis (pkey, kid32, ¶ms);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_mpi_dprint (params.params[0], m);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
ret = _gnutls_mpi_dprint (params.params[1], e);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (m);
goto cleanup;
}
ret = _gnutls_mpi_dprint (params.params[2], d);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (m);
_gnutls_free_datum (e);
goto cleanup;
}
ret = _gnutls_mpi_dprint (params.params[3], p);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (m);
_gnutls_free_datum (e);
_gnutls_free_datum (d);
goto cleanup;
}
ret = _gnutls_mpi_dprint (params.params[4], q);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (m);
_gnutls_free_datum (e);
_gnutls_free_datum (d);
_gnutls_free_datum (p);
goto cleanup;
}
ret = _gnutls_mpi_dprint (params.params[5], u);
if (ret < 0)
{
gnutls_assert ();
_gnutls_free_datum (q);
_gnutls_free_datum (m);
_gnutls_free_datum (e);
_gnutls_free_datum (d);
_gnutls_free_datum (p);
goto cleanup;
}
ret = 0;
cleanup:
gnutls_pk_params_release(¶ms);
return ret;
}
|
↓
|
_gnutls_privkey_decode_ecc_key
|
11
|
55
|
103
|
x509/privkey.c
|
ASN1_TYPE
_gnutls_privkey_decode_ecc_key (const gnutls_datum_t * raw_key,
gnutls_x509_privkey_t pkey)
{
int ret;
ASN1_TYPE pkey_asn;
unsigned int version;
char oid[MAX_OID_SIZE];
int oid_size;
gnutls_datum out;
gnutls_pk_params_init(&pkey->params);
if ((ret =
asn1_create_element (_gnutls_get_gnutls_asn (),
"GNUTLS.ECPrivateKey",
&pkey_asn)) != ASN1_SUCCESS)
{
gnutls_assert ();
return NULL;
}
ret = asn1_der_decoding (&pkey_asn, raw_key->data, raw_key->size, NULL);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
goto error;
}
ret = _gnutls_x509_read_uint (pkey_asn, "Version", &version);
if (ret < 0)
{
gnutls_assert();
goto error;
}
if (version != 1)
{
_gnutls_debug_log("ECC private key version %u is not supported\n", version);
gnutls_assert();
goto error;
}
/* read the curve */
oid_size = sizeof(oid);
ret = asn1_read_value(pkey_asn, "parameters.namedCurve", oid, &oid_size);
if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
goto error;
}
pkey->params.flags = _gnutls_oid_to_ecc_curve(oid);
if (pkey->params.flags == GNUTLS_ECC_CURVE_INVALID)
{
_gnutls_debug_log("Curve %s is not supported\n", oid);
gnutls_assert();
goto error;
}
ret = _gnutls_ecc_curve_fill_params(pkey->params.flags, &pkey->params);
if (ret < 0)
{
gnutls_assert();
goto error;
}
/* read the public key */
ret = _gnutls_x509_read_value(pkey_asn, "publicKey", &out, 2);
if (ret < 0)
{
gnutls_assert();
goto error;
}
ret = _gnutls_ecc_ansi_x963_import (out.data, out.size, &pkey->params.params[ECC_X],
&pkey->params.params[ECC_Y]);
_gnutls_free_datum(&out);
if (ret < 0)
{
gnutls_assert();
goto error;
}
pkey->params.params_nr += 2;
/* read the private key */
ret = _gnutls_x509_read_int (pkey_asn, "privateKey", &pkey->params.params[ECC_K]);
if (ret < 0)
{
gnutls_assert();
goto error;
}
pkey->params.params_nr ++;
return pkey_asn;
error:
asn1_delete_structure (&pkey_asn);
gnutls_pk_params_release (&pkey->params);
return NULL;
}
|
↓
|
_gnutls_server_name_recv_params
|
11
|
52
|
106
|
ext/server_name.c
|
static int
_gnutls_server_name_recv_params (gnutls_session_t session,
const opaque * data, size_t _data_size)
{
int i;
const unsigned char *p;
uint16_t len, type;
ssize_t data_size = _data_size;
int server_names = 0;
server_name_ext_st *priv;
extension_priv_data_t epriv;
if (session->security_parameters.entity == GNUTLS_SERVER)
{
DECR_LENGTH_RET (data_size, 2, 0);
len = _gnutls_read_uint16 (data);
if (len != data_size)
{
/* This is unexpected packet length, but
* just ignore it, for now.
*/
gnutls_assert ();
return 0;
}
p = data + 2;
/* Count all server_names in the packet. */
while (data_size > 0)
{
DECR_LENGTH_RET (data_size, 1, 0);
p++;
DECR_LEN (data_size, 2);
len = _gnutls_read_uint16 (p);
p += 2;
if (len > 0)
{
DECR_LENGTH_RET (data_size, len, 0);
server_names++;
p += len;
}
else
_gnutls_handshake_log
("HSK[%p]: Received (0) size server name (under attack?)\n",
session);
}
/* we cannot accept more server names.
*/
if (server_names > MAX_SERVER_NAME_EXTENSIONS)
{
_gnutls_handshake_log
("HSK[%p]: Too many server names received (under attack?)\n",
session);
server_names = MAX_SERVER_NAME_EXTENSIONS;
}
if (server_names == 0)
return 0; /* no names found */
priv = gnutls_calloc (1, sizeof (*priv));
if (priv == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
priv->server_names_size = server_names;
p = data + 2;
for (i = 0; i < server_names; i++)
{
type = *p;
p++;
len = _gnutls_read_uint16 (p);
p += 2;
switch (type)
{
case 0: /* NAME_DNS */
if (len <= MAX_SERVER_NAME_SIZE)
{
memcpy (priv->server_names[i].name, p, len);
priv->server_names[i].name_length = len;
priv->server_names[i].type = GNUTLS_NAME_DNS;
break;
}
}
/* move to next record */
p += len;
}
epriv.ptr = priv;
_gnutls_ext_set_session_data (session, GNUTLS_EXTENSION_SERVER_NAME,
epriv);
}
return 0;
}
|
↓
|
_gnutls_pbkdf2_sha1
|
11
|
52
|
144
|
x509/pbkdf2-sha1.c
|
int
_gnutls_pbkdf2_sha1 (const char *P, size_t Plen,
const char *S, size_t Slen,
unsigned int c, char *DK, size_t dkLen)
{
unsigned int hLen = 20;
char U[20];
char T[20];
unsigned int u;
unsigned int l;
unsigned int r;
unsigned int i;
unsigned int k;
int rc;
char *tmp;
size_t tmplen = Slen + 4;
if (c == 0)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (dkLen == 0)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
/*
*
* Steps:
*
* 1. If dkLen > (2^32 - 1) * hLen, output "derived key too long" and
* stop.
*/
if (dkLen > 4294967295U)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
/*
* 2. Let l be the number of hLen-octet blocks in the derived key,
* rounding up, and let r be the number of octets in the last
* block:
*
* l = CEIL (dkLen / hLen) ,
* r = dkLen - (l - 1) * hLen .
*
* Here, CEIL (x) is the "ceiling" function, i.e. the smallest
* integer greater than, or equal to, x.
*/
l = ((dkLen - 1) / hLen) + 1;
r = dkLen - (l - 1) * hLen;
/*
* 3. For each block of the derived key apply the function F defined
* below to the password P, the salt S, the iteration count c, and
* the block index to compute the block:
*
* T_1 = F (P, S, c, 1) ,
* T_2 = F (P, S, c, 2) ,
* ...
* T_l = F (P, S, c, l) ,
*
* where the function F is defined as the exclusive-or sum of the
* first c iterates of the underlying pseudorandom function PRF
* applied to the password P and the concatenation of the salt S
* and the block index i:
*
* F (P, S, c, i) = U_1 \xor U_2 \xor ... \xor U_c
*
* where
*
* U_1 = PRF (P, S || INT (i)) ,
* U_2 = PRF (P, U_1) ,
* ...
* U_c = PRF (P, U_{c-1}) .
*
* Here, INT (i) is a four-octet encoding of the integer i, most
* significant octet first.
*
* 4. Concatenate the blocks and extract the first dkLen octets to
* produce a derived key DK:
*
* DK = T_1 || T_2 || ... || T_l<0..r-1>
*
* 5. Output the derived key DK.
*
* Note. The construction of the function F follows a "belt-and-
* suspenders" approach. The iterates U_i are computed recursively to
* remove a degree of parallelism from an opponent; they are exclusive-
* ored together to reduce concerns about the recursion degenerating
* into a small set of values.
*
*/
tmp = gnutls_malloc (tmplen);
if (tmp == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
memcpy (tmp, S, Slen);
for (i = 1; i <= l; i++)
{
memset (T, 0, hLen);
for (u = 1; u <= c; u++)
{
if (u == 1)
{
tmp[Slen + 0] = (i & 0xff000000) >> 24;
tmp[Slen + 1] = (i & 0x00ff0000) >> 16;
tmp[Slen + 2] = (i & 0x0000ff00) >> 8;
tmp[Slen + 3] = (i & 0x000000ff) >> 0;
rc =
_gnutls_hmac_fast (GNUTLS_MAC_SHA1, P, Plen, tmp, tmplen, U);
}
else
rc = _gnutls_hmac_fast (GNUTLS_MAC_SHA1, P, Plen, U, hLen, U);
if (rc < 0)
{
gnutls_free (tmp);
return rc;
}
for (k = 0; k < hLen; k++)
T[k] ^= U[k];
}
memcpy (DK + (i - 1) * hLen, T, i == l ? r : hLen);
}
gnutls_free (tmp);
return 0;
}
|
↓
|
gnutls_dh_params_import_pkcs3
|
11
|
50
|
104
|
gnutls_dh_primes.c
|
int
gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t params,
const gnutls_datum_t * pkcs3_params,
gnutls_x509_crt_fmt_t format)
{
ASN1_TYPE c2;
int result, need_free = 0;
unsigned int q_bits;
gnutls_datum_t _params;
if (format == GNUTLS_X509_FMT_PEM)
{
opaque *out;
result = _gnutls_fbase64_decode ("DH PARAMETERS",
pkcs3_params->data,
pkcs3_params->size, &out);
if (result <= 0)
{
if (result == 0)
result = GNUTLS_E_INTERNAL_ERROR;
gnutls_assert ();
return result;
}
_params.data = out;
_params.size = result;
need_free = 1;
}
else
{
_params.data = pkcs3_params->data;
_params.size = pkcs3_params->size;
}
if ((result = asn1_create_element
(_gnutls_get_gnutls_asn (), "GNUTLS.DHParameter", &c2))
!= ASN1_SUCCESS)
{
gnutls_assert ();
if (need_free != 0)
{
gnutls_free (_params.data);
_params.data = NULL;
}
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, _params.data, _params.size, NULL);
if (need_free != 0)
{
gnutls_free (_params.data);
_params.data = NULL;
}
if (result != ASN1_SUCCESS)
{
/* couldn't decode DER */
_gnutls_debug_log ("DHParams: Decoding error %d\n", result);
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
/* Read q length */
result = _gnutls_x509_read_uint (c2, "privateValueLength", &q_bits);
if (result < 0)
{
gnutls_assert ();
params->q_bits = 0;
}
else
params->q_bits = q_bits;
/* Read PRIME
*/
result = _gnutls_x509_read_int (c2, "prime", ¶ms->params[0]);
if (result < 0)
{
asn1_delete_structure (&c2);
gnutls_assert ();
return result;
}
/* read the generator
*/
result = _gnutls_x509_read_int (c2, "base", ¶ms->params[1]);
if (result < 0)
{
asn1_delete_structure (&c2);
_gnutls_mpi_release (¶ms->params[0]);
gnutls_assert ();
return result;
}
asn1_delete_structure (&c2);
return 0;
}
|
↓
|
find_signercert
|
11
|
48
|
75
|
x509/ocsp.c
|
static gnutls_x509_crt_t
find_signercert (gnutls_ocsp_resp_t resp)
{
int rc;
gnutls_x509_crt_t * certs;
size_t ncerts = 0, i;
gnutls_datum_t riddn;
gnutls_x509_crt_t signercert = NULL;
rc = gnutls_ocsp_resp_get_responder (resp, &riddn);
if (rc != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
return NULL;
}
rc = gnutls_ocsp_resp_get_certs (resp, &certs, &ncerts);
if (rc != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
gnutls_free (riddn.data);
return NULL;
}
for (i = 0; i < ncerts; i++)
{
char *crtdn;
size_t crtdnsize = 0;
int cmpok;
rc = gnutls_x509_crt_get_dn (certs[i], NULL, &crtdnsize);
if (rc != GNUTLS_E_SHORT_MEMORY_BUFFER)
{
gnutls_assert ();
goto quit;
}
crtdn = gnutls_malloc (crtdnsize);
if (crtdn == NULL)
{
gnutls_assert ();
goto quit;
}
rc = gnutls_x509_crt_get_dn (certs[i], crtdn, &crtdnsize);
if (rc != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
gnutls_free (crtdn);
goto quit;
}
cmpok = (crtdnsize == riddn.size)
&& memcmp (riddn.data, crtdn, crtdnsize);
gnutls_free (crtdn);
if (cmpok == 0)
{
signercert = certs[i];
goto quit;
}
}
gnutls_assert ();
signercert = NULL;
quit:
gnutls_free (riddn.data);
for (i = 0; i < ncerts; i++)
if (certs[i] != signercert)
gnutls_x509_crt_deinit (certs[i]);
gnutls_free (certs);
return signercert;
}
|
↓
|
_gnutls_x509_crq_set_extension
|
11
|
46
|
92
|
x509/extensions.c
|
int
_gnutls_x509_crq_set_extension (gnutls_x509_crq_t crq,
const char *ext_id,
const gnutls_datum_t * ext_data,
unsigned int critical)
{
unsigned char *extensions = NULL;
size_t extensions_size = 0;
gnutls_datum_t der;
ASN1_TYPE c2;
int result;
result = gnutls_x509_crq_get_attribute_by_oid (crq, "1.2.840.113549.1.9.14",
0, NULL, &extensions_size);
if (result == GNUTLS_E_SHORT_MEMORY_BUFFER)
{
extensions = gnutls_malloc (extensions_size);
if (extensions == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = gnutls_x509_crq_get_attribute_by_oid (crq,
"1.2.840.113549.1.9.14",
0, extensions,
&extensions_size);
}
if (result < 0)
{
if (result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
{
extensions_size = 0;
}
else
{
gnutls_assert ();
gnutls_free (extensions);
return result;
}
}
result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.Extensions", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (extensions);
return _gnutls_asn2err (result);
}
if (extensions_size > 0)
{
result = asn1_der_decoding (&c2, extensions, extensions_size, NULL);
gnutls_free (extensions);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
}
result = set_extension (c2, "", ext_id, ext_data, critical);
if (result < 0)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return result;
}
result = _gnutls_x509_der_encode (c2, "", &der, 0);
asn1_delete_structure (&c2);
if (result < 0)
{
gnutls_assert ();
return result;
}
result = gnutls_x509_crq_set_attribute_by_oid (crq, "1.2.840.113549.1.9.14",
der.data, der.size);
gnutls_free (der.data);
if (result < 0)
{
gnutls_assert ();
return result;
}
return 0;
}
|
↓
|
find_privkeys
|
11
|
46
|
88
|
pkcs11.c
|
static int
find_privkeys (struct ck_function_list *module, ck_session_handle_t pks,
struct token_info *info, struct pkey_list *list)
{
struct ck_attribute a[3];
ck_object_class_t class;
ck_rv_t rv;
ck_object_handle_t obj;
unsigned long count, current;
char certid_tmp[PKCS11_ID_SIZE];
class = CKO_PRIVATE_KEY;
/* Find an object with private key class and a certificate ID
* which matches the certificate. */
/* FIXME: also match the cert subject. */
a[0].type = CKA_CLASS;
a[0].value = &class;
a[0].value_len = sizeof class;
rv = pkcs11_find_objects_init (module, pks, a, 1);
if (rv != CKR_OK)
{
gnutls_assert ();
return pkcs11_rv_to_err (rv);
}
list->key_ids_size = 0;
while (pkcs11_find_objects (module, pks, &obj, 1, &count) == CKR_OK && count == 1)
{
list->key_ids_size++;
}
pkcs11_find_objects_final (module, pks);
if (list->key_ids_size == 0)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
list->key_ids =
gnutls_malloc (sizeof (gnutls_buffer_st) * list->key_ids_size);
if (list->key_ids == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* actual search */
a[0].type = CKA_CLASS;
a[0].value = &class;
a[0].value_len = sizeof class;
rv = pkcs11_find_objects_init (module, pks, a, 1);
if (rv != CKR_OK)
{
gnutls_assert ();
return pkcs11_rv_to_err (rv);
}
current = 0;
while (pkcs11_find_objects (module, pks, &obj, 1, &count) == CKR_OK && count == 1)
{
a[0].type = CKA_ID;
a[0].value = certid_tmp;
a[0].value_len = sizeof (certid_tmp);
_gnutls_buffer_init (&list->key_ids[current]);
if (pkcs11_get_attribute_value (module, pks, obj, a, 1) == CKR_OK)
{
_gnutls_buffer_append_data (&list->key_ids[current],
a[0].value, a[0].value_len);
current++;
}
if (current > list->key_ids_size)
break;
}
pkcs11_find_objects_final (module, pks);
list->key_ids_size = current - 1;
return 0;
}
|
↓
|
gnutls_x509_crq_get_key_purpose_oid
|
11
|
46
|
88
|
x509/crq.c
|
int
gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t crq,
int indx, void *oid, size_t * sizeof_oid,
unsigned int *critical)
{
char tmpstr[ASN1_MAX_NAME_SIZE];
int result, len;
gnutls_datum_t prev = { NULL, 0 };
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
size_t prev_size = 0;
if (oid)
memset (oid, 0, *sizeof_oid);
else
*sizeof_oid = 0;
/* Extract extension.
*/
result = gnutls_x509_crq_get_extension_by_oid (crq, "2.5.29.37", 0,
NULL, &prev_size, critical);
prev.size = prev_size;
if (result < 0)
{
gnutls_assert ();
return result;
}
prev.data = gnutls_malloc (prev.size);
if (prev.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = gnutls_x509_crq_get_extension_by_oid (crq, "2.5.29.37", 0,
prev.data, &prev_size,
critical);
if (result < 0)
{
gnutls_assert ();
gnutls_free (prev.data);
return result;
}
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.ExtKeyUsageSyntax", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
gnutls_free (prev.data);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, prev.data, prev.size, NULL);
gnutls_free (prev.data);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
indx++;
/* create a string like "?1"
*/
snprintf (tmpstr, sizeof (tmpstr), "?%u", indx);
len = *sizeof_oid;
result = asn1_read_value (c2, tmpstr, oid, &len);
*sizeof_oid = len;
asn1_delete_structure (&c2);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (result != ASN1_SUCCESS)
{
if (result != ASN1_MEM_ERROR)
gnutls_assert ();
return _gnutls_asn2err (result);
}
return 0;
}
|
↓
|
gnutls_x509_crt_set_crq_extensions
|
11
|
45
|
76
|
x509/x509_write.c
|
int
gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt,
gnutls_x509_crq_t crq)
{
size_t i;
if (crt == NULL || crq == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
for (i = 0;; i++)
{
int result;
char oid[MAX_OID_SIZE];
size_t oid_size;
opaque *extensions;
size_t extensions_size;
unsigned int critical;
gnutls_datum_t ext;
oid_size = sizeof (oid);
result = gnutls_x509_crq_get_extension_info (crq, i, oid,
&oid_size, &critical);
if (result < 0)
{
if (result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
gnutls_assert ();
return result;
}
extensions_size = 0;
result = gnutls_x509_crq_get_extension_data (crq, i, NULL,
&extensions_size);
if (result < 0)
{
gnutls_assert ();
return result;
}
extensions = gnutls_malloc (extensions_size);
if (extensions == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
result = gnutls_x509_crq_get_extension_data (crq, i, extensions,
&extensions_size);
if (result < 0)
{
gnutls_assert ();
gnutls_free (extensions);
return result;
}
ext.data = extensions;
ext.size = extensions_size;
result = _gnutls_x509_crt_set_extension (crt, oid, &ext, critical);
gnutls_free (extensions);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
if (i > 0)
crt->use_extensions = 1;
return 0;
}
|
↓
|
gnutls_certificate_set_openpgp_key_mem2
|
11
|
43
|
77
|
openpgp/gnutls_openpgp.c
|
int
gnutls_certificate_set_openpgp_key_mem2 (gnutls_certificate_credentials_t res,
const gnutls_datum_t * cert,
const gnutls_datum_t * key,
const char *subkey_id,
gnutls_openpgp_crt_fmt_t format)
{
gnutls_openpgp_privkey_t pkey;
gnutls_openpgp_crt_t crt;
int ret;
uint8_t keyid[GNUTLS_OPENPGP_KEYID_SIZE];
ret = gnutls_openpgp_privkey_init (&pkey);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = gnutls_openpgp_privkey_import (pkey, key, format, NULL, 0);
if (ret < 0)
{
gnutls_assert ();
gnutls_openpgp_privkey_deinit (pkey);
return ret;
}
ret = gnutls_openpgp_crt_init (&crt);
if (ret < 0)
{
gnutls_assert ();
gnutls_openpgp_privkey_deinit (pkey);
return ret;
}
ret = gnutls_openpgp_crt_import (crt, cert, format);
if (ret < 0)
{
gnutls_assert ();
gnutls_openpgp_privkey_deinit (pkey);
gnutls_openpgp_crt_deinit (crt);
return ret;
}
if (subkey_id != NULL)
{
if (strcasecmp (subkey_id, "auto") == 0)
ret = gnutls_openpgp_crt_get_auth_subkey (crt, keyid, 1);
else
ret = get_keyid (keyid, subkey_id);
if (ret < 0)
gnutls_assert ();
if (ret >= 0)
{
ret = gnutls_openpgp_crt_set_preferred_key_id (crt, keyid);
if (ret >= 0)
ret = gnutls_openpgp_privkey_set_preferred_key_id (pkey, keyid);
}
if (ret < 0)
{
gnutls_assert ();
gnutls_openpgp_privkey_deinit (pkey);
gnutls_openpgp_crt_deinit (crt);
return ret;
}
}
ret = gnutls_certificate_set_openpgp_key (res, crt, pkey);
gnutls_openpgp_crt_deinit (crt);
gnutls_openpgp_privkey_deinit (pkey);
return ret;
}
|
↓
|
proc_rsa_export_client_kx
|
11
|
43
|
108
|
auth/rsa_export.c
|
int
proc_rsa_export_client_kx (gnutls_session_t session, opaque * data,
size_t _data_size)
{
gnutls_datum_t plaintext;
gnutls_datum_t ciphertext;
int ret, dsize;
gnutls_pk_params_st *params;
int randomize_key = 0;
ssize_t data_size = _data_size;
if (gnutls_protocol_get_version (session) == GNUTLS_SSL3)
{
/* SSL 3.0
*/
ciphertext.data = data;
ciphertext.size = data_size;
}
else
{
/* TLS 1.0
*/
DECR_LEN (data_size, 2);
ciphertext.data = &data[2];
dsize = _gnutls_read_uint16 (data);
if (dsize != data_size)
{
gnutls_assert ();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
ciphertext.size = dsize;
}
ret = _gnutls_get_private_rsa_params (session, ¶ms);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
ret = _gnutls_pkcs1_rsa_decrypt (&plaintext, &ciphertext, params, 2); /* btype==2 */
if (ret < 0 || plaintext.size != GNUTLS_MASTER_SIZE)
{
/* In case decryption fails then don't inform
* the peer. Just use a random key. (in order to avoid
* attack against pkcs-1 formating).
*/
gnutls_assert ();
_gnutls_audit_log (session, "auth_rsa: Possible PKCS #1 format attack\n");
randomize_key = 1;
}
else
{
/* If the secret was properly formatted, then
* check the version number.
*/
if (_gnutls_get_adv_version_major (session) != plaintext.data[0]
|| _gnutls_get_adv_version_minor (session) != plaintext.data[1])
{
/* No error is returned here, if the version number check
* fails. We proceed normally.
* That is to defend against the attack described in the paper
* "Attacking RSA-based sessions in SSL/TLS" by Vlastimil Klima,
* Ondej Pokorny and Tomas Rosa.
*/
gnutls_assert ();
_gnutls_audit_log
(session, "auth_rsa: Possible PKCS #1 version check format attack\n");
}
}
if (randomize_key != 0)
{
session->key->key.size = GNUTLS_MASTER_SIZE;
session->key->key.data = gnutls_malloc (session->key->key.size);
if (session->key->key.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* we do not need strong random numbers here.
*/
ret = _gnutls_rnd (GNUTLS_RND_NONCE, session->key->key.data,
session->key->key.size);
if (ret < 0)
{
gnutls_assert ();
return ret;
}
}
else
{
session->key->key.data = plaintext.data;
session->key->key.size = plaintext.size;
}
/* This is here to avoid the version check attack
* discussed above.
*/
session->key->key.data[0] = _gnutls_get_adv_version_major (session);
session->key->key.data[1] = _gnutls_get_adv_version_minor (session);
return 0;
}
|
↓
|
_gnutls_asn1_encode_ecc
|
11
|
42
|
81
|
x509/key_encode.c
|
static int
_gnutls_asn1_encode_ecc (ASN1_TYPE * c2, gnutls_pk_params_st * params)
{
int ret;
opaque one = '\x01';
gnutls_datum pubkey = { NULL, 0 };
const char *oid;
oid = _gnutls_ecc_curve_get_oid(params->flags);
if (params->params_nr != ECC_PRIVATE_PARAMS || oid == NULL)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
ret = _gnutls_ecc_ansi_x963_export(params->flags, params->params[ECC_X], params->params[ECC_Y], &pubkey);
if (ret < 0)
return gnutls_assert_val(ret);
/* Ok. Now we have the data. Create the asn1 structures
*/
/* first make sure that no previously allocated data are leaked */
if (*c2 != ASN1_TYPE_EMPTY)
{
asn1_delete_structure (c2);
*c2 = ASN1_TYPE_EMPTY;
}
if ((ret = asn1_create_element
(_gnutls_get_gnutls_asn (), "GNUTLS.ECPrivateKey", c2))
!= ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
if ((ret = asn1_write_value (*c2, "Version", &one, 1)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
ret = _gnutls_x509_write_int (*c2, "privateKey", params->params[ECC_K], 1);
if (ret < 0)
{
gnutls_assert ();
goto cleanup;
}
if ((ret = asn1_write_value (*c2, "publicKey", pubkey.data, pubkey.size*8)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
/* write our choice */
if ((ret = asn1_write_value (*c2, "parameters", "namedCurve", 1)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
if ((ret = asn1_write_value (*c2, "parameters.namedCurve", oid, 1)) != ASN1_SUCCESS)
{
gnutls_assert ();
ret = _gnutls_asn2err (ret);
goto cleanup;
}
_gnutls_free_datum(&pubkey);
return 0;
cleanup:
asn1_delete_structure (c2);
_gnutls_free_datum(&pubkey);
return ret;
}
|
↓
|
gnutls_pkcs7_get_crt_raw
|
11
|
42
|
89
|
x509/pkcs7.c
|
int
gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7,
int indx, void *certificate,
size_t * certificate_size)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int result, len;
char root2[ASN1_MAX_NAME_SIZE];
char oid[MAX_OID_SIZE];
gnutls_datum_t tmp = { NULL, 0 };
if (certificate_size == NULL || pkcs7 == NULL)
return GNUTLS_E_INVALID_REQUEST;
/* Step 1. decode the signed data.
*/
result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, &tmp);
if (result < 0)
{
gnutls_assert ();
return result;
}
/* Step 2. Parse the CertificateSet
*/
snprintf (root2, sizeof (root2), "certificates.?%u", indx + 1);
len = sizeof (oid) - 1;
result = asn1_read_value (c2, root2, oid, &len);
if (result == ASN1_VALUE_NOT_FOUND)
{
result = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
goto cleanup;
}
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* if 'Certificate' is the choice found:
*/
if (strcmp (oid, "certificate") == 0)
{
int start, end;
result = asn1_der_decoding_startEnd (c2, tmp.data, tmp.size,
root2, &start, &end);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
end = end - start + 1;
if ((unsigned) end > *certificate_size)
{
*certificate_size = end;
result = GNUTLS_E_SHORT_MEMORY_BUFFER;
goto cleanup;
}
if (certificate)
memcpy (certificate, &tmp.data[start], end);
*certificate_size = end;
result = 0;
}
else
{
result = GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE;
}
cleanup:
_gnutls_free_datum (&tmp);
if (c2)
asn1_delete_structure (&c2);
return result;
}
|
↓
|
gnutls_x509_trust_list_verify_crt
|
11
|
39
|
79
|
x509/verify-high.c
|
int
gnutls_x509_trust_list_verify_crt(gnutls_x509_trust_list_t list,
gnutls_x509_crt_t * cert_list,
unsigned int cert_list_size,
unsigned int flags,
unsigned int *verify,
gnutls_verify_output_function func)
{
gnutls_datum_t dn;
int ret, i;
uint32_t hash;
if (cert_list == NULL || cert_list_size < 1)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
cert_list_size = shorten_clist(list, cert_list, cert_list_size);
if (cert_list_size <= 0)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
ret =
gnutls_x509_crt_get_raw_issuer_dn(cert_list[cert_list_size - 1],
&dn);
if (ret < 0) {
gnutls_assert();
return ret;
}
hash = _gnutls_bhash(dn.data, dn.size, INIT_HASH);
hash %= list->size;
_gnutls_free_datum(&dn);
*verify = _gnutls_x509_verify_certificate(cert_list, cert_list_size,
list->node[hash].trusted_cas,
list->node[hash].
trusted_ca_size, flags,
func);
if (*verify != 0 || (flags & GNUTLS_VERIFY_DISABLE_CRL_CHECKS))
return 0;
/* Check revocation of individual certificates.
* start with the last one that we already have its hash
*/
ret = _gnutls_x509_crt_check_revocation(cert_list[cert_list_size - 1],
list->node[hash].crls,
list->node[hash].crl_size,
func);
if (ret == 1) { /* revoked */
*verify |= GNUTLS_CERT_REVOKED;
*verify |= GNUTLS_CERT_INVALID;
return 0;
}
for (i = 0; i < cert_list_size - 1; i++) {
ret = gnutls_x509_crt_get_raw_issuer_dn(cert_list[i], &dn);
if (ret < 0) {
gnutls_assert();
return ret;
}
hash = _gnutls_bhash(dn.data, dn.size, INIT_HASH);
hash %= list->size;
_gnutls_free_datum(&dn);
ret = _gnutls_x509_crt_check_revocation(cert_list[i],
list->node[hash].crls,
list->node[hash].crl_size,
func);
if (ret == 1) { /* revoked */
*verify |= GNUTLS_CERT_REVOKED;
*verify |= GNUTLS_CERT_INVALID;
return 0;
}
}
return 0;
}
|
↓
|
gnutls_x509_crt_import
|
11
|
39
|
87
|
x509/x509.c
|
int
gnutls_x509_crt_import (gnutls_x509_crt_t cert,
const gnutls_datum_t * data,
gnutls_x509_crt_fmt_t format)
{
int result = 0, need_free = 0;
gnutls_datum_t _data;
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
_data.data = data->data;
_data.size = data->size;
/* If the Certificate is in PEM format then decode it
*/
if (format == GNUTLS_X509_FMT_PEM)
{
opaque *out;
/* Try the first header */
result =
_gnutls_fbase64_decode (PEM_X509_CERT2, data->data, data->size, &out);
if (result <= 0)
{
/* try for the second header */
result =
_gnutls_fbase64_decode (PEM_X509_CERT, data->data,
data->size, &out);
if (result <= 0)
{
if (result == 0)
result = GNUTLS_E_INTERNAL_ERROR;
gnutls_assert ();
return result;
}
}
_data.data = out;
_data.size = result;
need_free = 1;
}
if (cert->cert)
{
/* Any earlier asn1_der_decoding will modify the ASN.1
structure, so we need to replace it with a fresh
structure. */
asn1_delete_structure (&cert->cert);
result = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.Certificate", &cert->cert);
if (result != ASN1_SUCCESS)
{
result = _gnutls_asn2err (result);
gnutls_assert ();
goto cleanup;
}
}
result = asn1_der_decoding (&cert->cert, _data.data, _data.size, NULL);
if (result != ASN1_SUCCESS)
{
result = _gnutls_asn2err (result);
gnutls_assert ();
goto cleanup;
}
/* Since we do not want to disable any extension
*/
cert->use_extensions = 1;
if (need_free)
_gnutls_free_datum (&_data);
return 0;
cleanup:
if (need_free)
_gnutls_free_datum (&_data);
return result;
}
|
↓
|
_gnutls_copy_certificate_auth_info
|
11
|
38
|
69
|
auth/cert.c
|
static int
_gnutls_copy_certificate_auth_info (cert_auth_info_t info, gnutls_pcert_st * certs, size_t ncerts, int subkey_used, /* openpgp only */
void *keyid)
{
/* Copy peer's information to auth_info_t
*/
int ret;
size_t i, j;
if (info->raw_certificate_list != NULL)
{
for (j = 0; j < info->ncerts; j++)
_gnutls_free_datum (&info->raw_certificate_list[j]);
gnutls_free (info->raw_certificate_list);
}
if (ncerts == 0)
{
info->raw_certificate_list = NULL;
info->ncerts = 0;
return 0;
}
info->raw_certificate_list =
gnutls_calloc (ncerts, sizeof (gnutls_datum_t));
if (info->raw_certificate_list == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
for (i = 0; i < ncerts; i++)
{
if (certs[i].cert.size > 0)
{
ret =
_gnutls_set_datum (&info->raw_certificate_list[i],
certs[i].cert.data, certs[i].cert.size);
if (ret < 0)
{
gnutls_assert ();
goto clear;
}
}
}
info->ncerts = ncerts;
info->cert_type = certs[0].type;
#ifdef ENABLE_OPENPGP
if (certs[0].type == GNUTLS_CRT_OPENPGP)
{
info->use_subkey = subkey_used;
if (keyid)
memcpy (info->subkey_id, keyid, GNUTLS_OPENPGP_KEYID_SIZE);
}
#endif
return 0;
clear:
for (j = 0; j < i; j++)
_gnutls_free_datum (&info->raw_certificate_list[j]);
gnutls_free (info->raw_certificate_list);
info->raw_certificate_list = NULL;
return ret;
}
|
↓
|
_dtls_record_check
|
11
|
38
|
81
|
gnutls_dtls.c
|
int _dtls_record_check(gnutls_session_t session, uint64 * _seq)
{
uint64_t seq = 0, diff;
int i, offset = 0;
for (i=0;i<8;i++)
{
seq |= _seq->i[i];
seq <<= 8;
}
if (window_size == 0)
{
window_size = 1;
window_table[0] = seq;
return 0;
}
if (seq <= window_table[0])
{
return -1;
}
if (window_size == DTLS_RECORD_WINDOW_SIZE) {
rot_window(session, MOVE_SIZE);
}
if (seq < window_table[window_size-1])
{
/* is between first and last */
diff = window_table[window_size-1] - seq;
if (diff >= window_size)
{
return -1;
}
offset = window_size-1-diff;
if (window_table[offset] == seq)
{
return -1;
}
else
{
window_table[offset] = seq;
}
}
else /* seq >= last */
{
if (seq == window_table[window_size-1])
{
return -1;
}
diff = seq - window_table[window_size-1];
if (diff <= DTLS_RECORD_WINDOW_SIZE - window_size)
{ /* fits in our empty space */
offset = diff + window_size-1;
window_table[offset] = seq;
window_size = offset + 1;
}
else
{
if (diff > DTLS_RECORD_WINDOW_SIZE/2)
{ /* difference is too big */
window_table[DTLS_RECORD_WINDOW_SIZE-1] = seq;
window_size = DTLS_RECORD_WINDOW_SIZE;
}
else
{
rot_window(session, diff);
offset = diff + window_size-1;
window_table[offset] = seq;
window_size = offset + 1;
}
}
}
return 0;
}
|
↓
|
gnutls_x509_crt_get_key_purpose_oid
|
11
|
38
|
78
|
x509/x509.c
|
int
gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
int indx, void *oid, size_t * oid_size,
unsigned int *critical)
{
char tmpstr[ASN1_MAX_NAME_SIZE];
int result, len;
gnutls_datum_t id;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (oid)
memset (oid, 0, *oid_size);
else
*oid_size = 0;
if ((result =
_gnutls_x509_crt_get_extension (cert, "2.5.29.37", 0, &id,
critical)) < 0)
{
return result;
}
if (id.size == 0 || id.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.ExtKeyUsageSyntax", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_free_datum (&id);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, id.data, id.size, NULL);
_gnutls_free_datum (&id);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
indx++;
/* create a string like "?1"
*/
snprintf (tmpstr, sizeof (tmpstr), "?%u", indx);
len = *oid_size;
result = asn1_read_value (c2, tmpstr, oid, &len);
*oid_size = len;
asn1_delete_structure (&c2);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
return 0;
}
|
↓
|
get_alt_name
|
11
|
38
|
80
|
x509/x509.c
|
static int
get_alt_name (gnutls_x509_crt_t cert, const char *extension_id,
unsigned int seq, void *ret,
size_t * ret_size, unsigned int *ret_type,
unsigned int *critical, int othername_oid)
{
int result;
gnutls_datum_t dnsname;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
gnutls_x509_subject_alt_name_t type;
if (cert == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (ret)
memset (ret, 0, *ret_size);
else
*ret_size = 0;
if ((result =
_gnutls_x509_crt_get_extension (cert, extension_id, 0, &dnsname,
critical)) < 0)
{
return result;
}
if (dnsname.size == 0 || dnsname.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (strcmp ("2.5.29.17", extension_id) == 0)
result = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.SubjectAltName", &c2);
else if (strcmp ("2.5.29.18", extension_id) == 0)
result = asn1_create_element (_gnutls_get_pkix (),
"PKIX1.IssuerAltName", &c2);
else
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_free_datum (&dnsname);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, dnsname.data, dnsname.size, NULL);
_gnutls_free_datum (&dnsname);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
result =
_gnutls_parse_general_name (c2, "", seq, ret, ret_size, ret_type,
othername_oid);
asn1_delete_structure (&c2);
if (result < 0)
{
gnutls_assert ();
return result;
}
type = result;
return type;
}
|
↓
|
gnutls_pkcs7_set_crt_raw
|
11
|
37
|
82
|
x509/pkcs7.c
|
int
gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7, const gnutls_datum_t * crt)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int result;
if (pkcs7 == NULL)
return GNUTLS_E_INVALID_REQUEST;
/* Step 1. decode the signed data.
*/
result = _decode_pkcs7_signed_data (pkcs7->pkcs7, &c2, NULL);
if (result < 0 && result != GNUTLS_E_ASN1_VALUE_NOT_FOUND)
{
gnutls_assert ();
return result;
}
/* If the signed data are uninitialized
* then create them.
*/
if (result == GNUTLS_E_ASN1_VALUE_NOT_FOUND)
{
/* The pkcs7 structure is new, so create the
* signedData.
*/
result = create_empty_signed_data (pkcs7->pkcs7, &c2);
if (result < 0)
{
gnutls_assert ();
return result;
}
}
/* Step 2. Append the new certificate.
*/
result = asn1_write_value (c2, "certificates", "NEW", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
result = asn1_write_value (c2, "certificates.?LAST", "certificate", 1);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
result =
asn1_write_value (c2, "certificates.?LAST.certificate", crt->data,
crt->size);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
result = _gnutls_asn2err (result);
goto cleanup;
}
/* Step 3. Replace the old content with the new
*/
result =
_gnutls_x509_der_encode_and_copy (c2, "", pkcs7->pkcs7, "content", 0);
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
asn1_delete_structure (&c2);
return 0;
cleanup:
if (c2)
asn1_delete_structure (&c2);
return result;
}
|
↓
|
_cdk_keydb_check_userid
|
11
|
37
|
57
|
opencdk/keydb.c
|
cdk_error_t
_cdk_keydb_check_userid (cdk_keydb_hd_t hd, u32 * keyid, const char *id)
{
cdk_kbnode_t knode = NULL, unode = NULL;
cdk_error_t rc;
int check;
cdk_keydb_search_t st;
if (!hd)
{
gnutls_assert ();
return CDK_Inv_Value;
}
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_KEYID, keyid);
if (rc)
{
gnutls_assert ();
return rc;
}
rc = cdk_keydb_search (st, hd, &knode);
cdk_keydb_search_release (st);
if (rc)
{
gnutls_assert ();
return rc;
}
rc = cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_EXACT, (char *) id);
if (!rc)
{
rc = cdk_keydb_search (st, hd, &unode);
cdk_keydb_search_release (st);
}
if (rc)
{
cdk_kbnode_release (knode);
gnutls_assert ();
return rc;
}
check = 0;
cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_KEYID, keyid);
if (unode && find_by_keyid (unode, st))
check++;
cdk_keydb_search_release (st);
cdk_kbnode_release (unode);
cdk_keydb_search_start (&st, hd, CDK_DBSEARCH_EXACT, (char *) id);
if (knode && find_by_pattern (knode, st))
check++;
cdk_keydb_search_release (st);
cdk_kbnode_release (knode);
return check == 2 ? 0 : CDK_Inv_Value;
}
|
↓
|
_gnutls_server_name_send_params
|
11
|
37
|
78
|
ext/server_name.c
|
static int
_gnutls_server_name_send_params (gnutls_session_t session,
gnutls_buffer_st* extdata)
{
uint16_t len;
unsigned i;
int total_size = 0, ret;
server_name_ext_st *priv;
extension_priv_data_t epriv;
ret =
_gnutls_ext_get_session_data (session, GNUTLS_EXTENSION_SERVER_NAME,
&epriv);
if (ret < 0)
return 0;
/* this function sends the client extension data (dnsname)
*/
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
priv = epriv.ptr;
if (priv->server_names_size == 0)
return 0;
/* uint16_t
*/
total_size = 2;
for (i = 0; i < priv->server_names_size; i++)
{
/* count the total size
*/
len = priv->server_names[i].name_length;
/* uint8_t + uint16_t + size
*/
total_size += 1 + 2 + len;
}
/* UINT16: write total size of all names
*/
ret = _gnutls_buffer_append_prefix(extdata, 16, total_size - 2);
if (ret < 0)
return gnutls_assert_val(ret);
for (i = 0; i < priv->server_names_size; i++)
{
switch (priv->server_names[i].type)
{
case GNUTLS_NAME_DNS:
len = priv->server_names[i].name_length;
if (len == 0)
break;
/* UINT8: type of this extension
* UINT16: size of the first name
* LEN: the actual server name.
*/
ret = _gnutls_buffer_append_prefix(extdata, 8, 0);
if (ret < 0)
return gnutls_assert_val(ret);
ret = _gnutls_buffer_append_data_prefix(extdata, 16, priv->server_names[i].name, len);
if (ret < 0)
return gnutls_assert_val(ret);
break;
default:
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
}
}
return total_size;
}
|
↓
|
gnutls_x509_privkey_import_pkcs8
|
11
|
36
|
84
|
x509/privkey_pkcs8.c
|
int
gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key,
const gnutls_datum_t * data,
gnutls_x509_crt_fmt_t format,
const char *password, unsigned int flags)
{
int result = 0, need_free = 0;
gnutls_datum_t _data;
if (key == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
_data.data = data->data;
_data.size = data->size;
key->pk_algorithm = GNUTLS_PK_UNKNOWN;
/* If the Certificate is in PEM format then decode it
*/
if (format == GNUTLS_X509_FMT_PEM)
{
opaque *out;
/* Try the first header
*/
result =
_gnutls_fbase64_decode (PEM_UNENCRYPTED_PKCS8,
data->data, data->size, &out);
if (result < 0)
{ /* Try the encrypted header
*/
result =
_gnutls_fbase64_decode (PEM_PKCS8, data->data, data->size, &out);
if (result <= 0)
{
if (result == 0)
result = GNUTLS_E_INTERNAL_ERROR;
gnutls_assert ();
return result;
}
}
else if (flags == 0)
flags |= GNUTLS_PKCS_PLAIN;
_data.data = out;
_data.size = result;
need_free = 1;
}
if (flags & GNUTLS_PKCS_PLAIN)
{
result = decode_private_key_info (&_data, key);
}
else
{ /* encrypted. */
result = decode_pkcs8_key (&_data, password, key);
}
if (result < 0)
{
gnutls_assert ();
goto cleanup;
}
if (need_free)
_gnutls_free_datum (&_data);
/* The key has now been decoded.
*/
return 0;
cleanup:
key->pk_algorithm = GNUTLS_PK_UNKNOWN;
if (need_free)
_gnutls_free_datum (&_data);
return result;
}
|
↓
|
gnutls_x509_crl_get_authority_key_id
|
11
|
35
|
72
|
x509/crl.c
|
int
gnutls_x509_crl_get_authority_key_id (gnutls_x509_crl_t crl, void *ret,
size_t * ret_size,
unsigned int *critical)
{
int result, len;
gnutls_datum_t id;
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
if (crl == NULL)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (ret)
memset (ret, 0, *ret_size);
else
*ret_size = 0;
if ((result =
_gnutls_x509_crl_get_extension (crl, "2.5.29.35", 0, &id,
critical)) < 0)
{
return result;
}
if (id.size == 0 || id.data == NULL)
{
gnutls_assert ();
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
result = asn1_create_element
(_gnutls_get_pkix (), "PKIX1.AuthorityKeyIdentifier", &c2);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
_gnutls_free_datum (&id);
return _gnutls_asn2err (result);
}
result = asn1_der_decoding (&c2, id.data, id.size, NULL);
_gnutls_free_datum (&id);
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
asn1_delete_structure (&c2);
return _gnutls_asn2err (result);
}
len = *ret_size;
result = asn1_read_value (c2, "keyIdentifier", ret, &len);
*ret_size = len;
asn1_delete_structure (&c2);
if (result == ASN1_VALUE_NOT_FOUND || result == ASN1_ELEMENT_NOT_FOUND)
{
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
if (result != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (result);
}
return 0;
}
|
↓
|
check_if_sorted
|
11
|
34
|
60
|
gnutls_x509.c
|
static int check_if_sorted(gnutls_pcert_st * crt, int nr)
{
gnutls_x509_crt_t x509;
char prev_dn[MAX_DN];
char dn[MAX_DN];
size_t prev_dn_size, dn_size;
int i, ret;
/* check if the X.509 list is ordered */
if (nr > 1 && crt[0].type == GNUTLS_CRT_X509)
{
for (i=0;i0)
{
dn_size = sizeof(dn);
ret = gnutls_x509_crt_get_dn(x509, dn, &dn_size);
if (ret < 0)
{
ret = gnutls_assert_val(ret);
goto cleanup;
}
if (dn_size != prev_dn_size || memcmp(dn, prev_dn, dn_size) != 0)
{
ret = gnutls_assert_val(GNUTLS_E_CERTIFICATE_LIST_UNSORTED);
goto cleanup;
}
}
prev_dn_size = sizeof(prev_dn);
ret = gnutls_x509_crt_get_issuer_dn(x509, prev_dn, &prev_dn_size);
if (ret < 0)
{
ret = gnutls_assert_val(ret);
goto cleanup;
}
gnutls_x509_crt_deinit(x509);
}
}
return 0;
cleanup:
gnutls_x509_crt_deinit(x509);
return ret;
}
|
↓
|
gnutls_ocsp_req_get_extension
|
11
|
34
|
66
|
x509/ocsp.c
|
int
gnutls_ocsp_req_get_extension (gnutls_ocsp_req_t req,
unsigned indx,
gnutls_datum_t *oid,
unsigned int *critical,
gnutls_datum_t *data)
{
int ret;
char str_critical[10];
char name[ASN1_MAX_NAME_SIZE];
int len;
if (!req)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
snprintf (name, sizeof (name), "tbsRequest.requestExtensions.?%u.critical",
indx + 1);
len = sizeof (str_critical);
ret = asn1_read_value (req->req, name, str_critical, &len);
if (ret == ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
else if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (ret);
}
if (critical)
{
if (str_critical[0] == 'T')
*critical = 1;
else
*critical = 0;
}
if (oid)
{
snprintf (name, sizeof (name),
"tbsRequest.requestExtensions.?%u.extnID", indx + 1);
ret = _gnutls_x509_read_value (req->req, name, oid, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
return ret;
}
}
if (data)
{
snprintf (name, sizeof (name),
"tbsRequest.requestExtensions.?%u.extnValue", indx + 1);
ret = _gnutls_x509_read_value (req->req, name, data, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
if (oid)
gnutls_free (oid->data);
return ret;
}
}
return GNUTLS_E_SUCCESS;
}
|
↓
|
gnutls_ocsp_resp_get_extension
|
11
|
34
|
67
|
x509/ocsp.c
|
int
gnutls_ocsp_resp_get_extension (gnutls_ocsp_resp_t resp,
unsigned indx,
gnutls_datum_t *oid,
unsigned int *critical,
gnutls_datum_t *data)
{
int ret;
char str_critical[10];
char name[ASN1_MAX_NAME_SIZE];
int len;
if (!resp)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
snprintf (name, sizeof (name),
"tbsResponseData.responseExtensions.?%u.critical",
indx + 1);
len = sizeof (str_critical);
ret = asn1_read_value (resp->basicresp, name, str_critical, &len);
if (ret == ASN1_ELEMENT_NOT_FOUND)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
else if (ret != ASN1_SUCCESS)
{
gnutls_assert ();
return _gnutls_asn2err (ret);
}
if (critical)
{
if (str_critical[0] == 'T')
*critical = 1;
else
*critical = 0;
}
if (oid)
{
snprintf (name, sizeof (name),
"tbsResponseData.responseExtensions.?%u.extnID", indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name, oid, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
return ret;
}
}
if (data)
{
snprintf (name, sizeof (name),
"tbsResponseData.responseExtensions.?%u.extnValue", indx + 1);
ret = _gnutls_x509_read_value (resp->basicresp, name, data, 0);
if (ret != GNUTLS_E_SUCCESS)
{
gnutls_assert ();
if (oid)
gnutls_free (oid->data);
return ret;
}
}
return GNUTLS_E_SUCCESS;
}
|
↓
|
_gnutls_read_pgp_mpi
|
11
|
34
|
84
|
openpgp/pgp.c
|
int
_gnutls_read_pgp_mpi (cdk_packet_t pkt, unsigned int priv, size_t idx,
bigint_t * m)
{
size_t buf_size = 512;
opaque *buf = gnutls_malloc (buf_size);
int err;
unsigned int max_pub_params = 0;
if (priv != 0)
max_pub_params = cdk_pk_get_npkey (pkt->pkt.secret_key->pk->pubkey_algo);
if (buf == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
/* FIXME: Note that opencdk doesn't like the buf to be NULL.
*/
if (priv == 0)
err =
cdk_pk_get_mpi (pkt->pkt.public_key, idx, buf, buf_size, &buf_size,
NULL);
else
{
if (idx < max_pub_params)
err =
cdk_pk_get_mpi (pkt->pkt.secret_key->pk, idx, buf, buf_size,
&buf_size, NULL);
else
{
err =
cdk_sk_get_mpi (pkt->pkt.secret_key, idx - max_pub_params, buf,
buf_size, &buf_size, NULL);
}
}
if (err == CDK_Too_Short)
{
buf = gnutls_realloc_fast (buf, buf_size);
if (buf == NULL)
{
gnutls_assert ();
return GNUTLS_E_MEMORY_ERROR;
}
if (priv == 0)
err =
cdk_pk_get_mpi (pkt->pkt.public_key, idx, buf, buf_size, &buf_size,
NULL);
else
{
if (idx < max_pub_params)
err =
cdk_pk_get_mpi (pkt->pkt.secret_key->pk, idx, buf, buf_size,
&buf_size, NULL);
else
{
err =
cdk_sk_get_mpi (pkt->pkt.secret_key, idx - max_pub_params,
buf, buf_size, &buf_size, NULL);
}
}
}
if (err != CDK_Success)
{
gnutls_assert ();
gnutls_free (buf);
return _gnutls_map_cdk_rc (err);
}
err = _gnutls_mpi_scan (m, buf, buf_size);
gnutls_free (buf);
if (err < 0)
{
gnutls_assert ();
return err;
}
return 0;
}
|
|
recv_headers
|
11
|
31
|
74
|
gnutls_record.c
|
|
↓
|
gnutls_openpgp_crt_get_name
|
11
|
31
|
56
|
openpgp/pgp.c
|
int
gnutls_openpgp_crt_get_name (gnutls_openpgp_crt_t key,
int idx, char *buf, size_t * sizeof_buf)
{
cdk_kbnode_t ctx = NULL, p;
cdk_packet_t pkt = NULL;
cdk_pkt_userid_t uid = NULL;
int pos = 0;
if (!key)
{
gnutls_assert ();
return GNUTLS_E_INVALID_REQUEST;
}
if (idx < 0 || idx >= _gnutls_openpgp_count_key_names (key))
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
pos = 0;
while ((p = cdk_kbnode_walk (key->knode, &ctx, 0)))
{
pkt = cdk_kbnode_get_packet (p);
if (pkt->pkttype == CDK_PKT_USER_ID)
{
if (pos == idx)
break;
pos++;
}
}
if (!pkt)
{
gnutls_assert ();
return GNUTLS_E_INTERNAL_ERROR;
}
uid = pkt->pkt.user_id;
if (uid->len >= *sizeof_buf)
{
gnutls_assert ();
*sizeof_buf = uid->len + 1;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
if (buf)
{
memcpy (buf, uid->name, uid->len);
buf[uid->len] = '\0'; /* make sure it's a string */
}
*sizeof_buf = uid->len + 1;
if (uid->is_revoked)
return GNUTLS_E_OPENPGP_UID_REVOKED;
return 0;
}
|
↓
|
do_device_source_urandom
|
11
|
31
|
64
|
nettle/rnd.c
|
static int
do_device_source_urandom (int init)
{
time_t now = gnutls_time (NULL);
int read_size = DEVICE_READ_SIZE;
if (init)
{
int old;
device_fd = open ("/dev/urandom", O_RDONLY);
if (device_fd < 0)
{
_gnutls_debug_log ("Cannot open urandom!\n");
return GNUTLS_E_FILE_ERROR;
}
old = fcntl (device_fd, F_GETFD);
fcntl (device_fd, F_SETFD, old | 1);
device_last_read = now;
read_size = DEVICE_READ_SIZE_MAX; /* initially read more data */
}
if ((device_fd > 0)
&& (init || ((now - device_last_read) > DEVICE_READ_INTERVAL)))
{
/* More than 20 minutes since we last read the device */
uint8_t buf[DEVICE_READ_SIZE_MAX];
uint32_t done;
for (done = 0; done < read_size;)
{
int res;
do
res = read (device_fd, buf + done, sizeof (buf) - done);
while (res < 0 && errno == EINTR);
if (res <= 0)
{
if (res < 0)
{
_gnutls_debug_log ("Failed to read /dev/urandom: %s\n",
strerror (errno));
}
else
{
_gnutls_debug_log
("Failed to read /dev/urandom: end of file\n");
}
return GNUTLS_E_INTERNAL_ERROR;
}
done += res;
}
device_last_read = now;
return yarrow256_update (&yctx, RANDOM_SOURCE_DEVICE,
read_size * 8 / 2 /* we trust the RNG */ ,
read_size, buf);
}
return 0;
}
|
↓
|
read_public_key
|
11
|
30
|
47
|
opencdk/read-packet.c
|
static cdk_error_t
read_public_key (cdk_stream_t inp, size_t pktlen, cdk_pkt_pubkey_t pk)
{
size_t i, ndays, npkey;
if (!inp || !pk)
return CDK_Inv_Value;
if (DEBUG_PKT)
_gnutls_write_log ("read_public_key: %d octets\n", (int) pktlen);
pk->is_invalid = 1; /* default to detect missing self signatures */
pk->is_revoked = 0;
pk->has_expired = 0;
pk->version = cdk_stream_getc (inp);
if (pk->version < 2 || pk->version > 4)
return CDK_Inv_Packet_Ver;
pk->timestamp = read_32 (inp);
if (pk->version < 4)
{
ndays = read_16 (inp);
if (ndays)
pk->expiredate = pk->timestamp + ndays * 86400L;
}
pk->pubkey_algo = _pgp_pub_algo_to_cdk (cdk_stream_getc (inp));
npkey = cdk_pk_get_npkey (pk->pubkey_algo);
if (!npkey)
{
gnutls_assert ();
_gnutls_write_log ("invalid public key algorithm %d\n",
pk->pubkey_algo);
return CDK_Inv_Algo;
}
for (i = 0; i < npkey; i++)
{
cdk_error_t rc = read_mpi (inp, &pk->mpi[i], 0);
if (rc)
return rc;
}
/* This value is just for the first run and will be
replaced with the actual key flags from the self signature. */
pk->pubkey_usage = 0;
return 0;
}
|
↓
|
gnutls_handshake
|
11
|
30
|
72
|
gnutls_handshake.c
|
int
gnutls_handshake (gnutls_session_t session)
{
int ret;
record_parameters_st *params;
/* sanity check. Verify that there are priorities setup.
*/
if (session->internals.priorities.protocol.algorithms == 0)
return gnutls_assert_val(GNUTLS_E_NO_PRIORITIES_WERE_SET);
ret = _gnutls_epoch_get (session, session->security_parameters.epoch_next,
¶ms);
if (ret < 0)
{
/* We assume the epoch is not allocated if _gnutls_epoch_get fails. */
ret =
_gnutls_epoch_alloc (session, session->security_parameters.epoch_next,
NULL);
if (ret < 0)
return gnutls_assert_val(ret);
}
if (session->security_parameters.entity == GNUTLS_CLIENT)
{
do
{
ret = _gnutls_handshake_client (session);
} while (ret == 1);
}
else
{
ret = _gnutls_handshake_server (session);
}
if (ret < 0)
{
/* In the case of a rehandshake abort
* we should reset the handshake's internal state.
*/
if (_gnutls_abort_handshake (session, ret) == 0)
STATE = STATE0;
return ret;
}
ret = _gnutls_handshake_common (session);
if (ret < 0)
{
if (_gnutls_abort_handshake (session, ret) == 0)
STATE = STATE0;
return ret;
}
STATE = STATE0;
if (IS_DTLS(session)==0)
{
_gnutls_handshake_io_buffer_clear (session);
}
else
{
_dtls_async_timer_init(session);
}
_gnutls_handshake_internal_state_clear (session);
session->security_parameters.epoch_next++;
return 0;
}
|
↓
|
_gnutls_supported_ciphersuites
|
11
|
28
|
44
|
algorithms/ciphersuites.c
|
int
_gnutls_supported_ciphersuites (gnutls_session_t session,
uint8_t *cipher_suites, int max_cipher_suite_size)
{
unsigned int i, ret_count, j, z, k=0;
const gnutls_cipher_suite_entry * ce;
int version = gnutls_protocol_get_version( session);
for (i = 0; i < session->internals.priorities.kx.algorithms; i++)
for (j = 0; j < session->internals.priorities.cipher.algorithms; j++)
for (z = 0; z < session->internals.priorities.mac.algorithms; z++)
{
ce = cipher_suite_get(session->internals.priorities.kx.priority[i],
session->internals.priorities.cipher.priority[j],
session->internals.priorities.mac.priority[z]);
if (ce == NULL) continue;
if (!(version >= ce->min_version && version <= ce->max_version))
continue;
if (IS_DTLS(session) && ce->dtls==0)
continue;
if (k+2 > max_cipher_suite_size)
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
memcpy (&cipher_suites[k], ce->id, 2);
k+=2;
}
ret_count = k;
/* This function can no longer return 0 cipher suites.
* It returns an error code instead.
*/
if (ret_count == 0)
{
gnutls_assert ();
return GNUTLS_E_NO_CIPHER_SUITES;
}
return ret_count;
}
|
↓
|
keydb_pos_from_cache
|
11
|
28
|
55
|
opencdk/keydb.c
|
static cdk_error_t
keydb_pos_from_cache (cdk_keydb_hd_t hd, cdk_keydb_search_t ks,
int *r_cache_hit, off_t * r_off)
{
key_table_t c;
if (!hd || !r_cache_hit || !r_off)
{
gnutls_assert ();
return CDK_Inv_Value;
}
/* Reset the values. */
*r_cache_hit = 0;
*r_off = 0;
c = keydb_cache_find (ks);
if (c != NULL)
{
_cdk_log_debug ("cache: found entry in cache.\n");
*r_cache_hit = 1;
*r_off = c->offset;
return 0;
}
/* No index cache available so we just return here. */
if (!ks->idx)
return 0;
if (ks->idx)
{
if (ks->type == CDK_DBSEARCH_KEYID)
{
if (keydb_idx_search (ks->idx, ks->u.keyid, NULL, r_off))
{
gnutls_assert ();
return CDK_Error_No_Key;
}
_cdk_log_debug ("cache: found keyid entry in idx table.\n");
*r_cache_hit = 1;
}
else if (ks->type == CDK_DBSEARCH_FPR)
{
if (keydb_idx_search (ks->idx, NULL, ks->u.fpr, r_off))
{
gnutls_assert ();
return CDK_Error_No_Key;
}
_cdk_log_debug ("cache: found fpr entry in idx table.\n");
*r_cache_hit = 1;
}
}
return 0;
}
|
↓
|
decode
|
11
|
27
|
37
|
auth/srp_sb64.c
|
inline static int
decode (uint8_t * result, const uint8_t * data)
{
uint8_t a1, a2;
int ret = 3;
memset (result, 0, 3);
a1 = TOASCII (data[3]);
a2 = TOASCII (data[2]);
if (a1 != 0xff)
result[2] = a1 & 0xff;
else
return -1;
if (a2 != 0xff)
result[2] |= ((a2 & 0x03) << 6) & 0xff;
a1 = a2;
a2 = TOASCII (data[1]);
if (a1 != 0xff)
result[1] = ((a1 & 0x3c) >> 2);
if (a2 != 0xff)
result[1] |= ((a2 & 0x0f) << 4);
else if (a1 == 0xff || result[1] == 0)
ret--;
a1 = a2;
a2 = TOASCII (data[0]);
if (a1 != 0xff)
result[0] = (((a1 & 0x30) >> 4) & 0xff);
if (a2 != 0xff)
result[0] |= ((a2 << 2) & 0xff);
else if (a1 == 0xff || result[0] == 0)
ret--;
return ret;
}
|
↓
|
compress_get_algo
|
11
|
20
|
32
|
opencdk/armor.c
|
static int
compress_get_algo (cdk_stream_t inp, int *r_zipalgo)
{
byte plain[512];
char buf[128];
int nread, pkttype;
*r_zipalgo = 0;
cdk_stream_seek (inp, 0);
while (!cdk_stream_eof (inp))
{
nread = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
if (!nread || nread == -1)
break;
if (nread == 1 && !cdk_stream_eof (inp)
&& (nread = _cdk_stream_gets (inp, buf, DIM (buf) - 1)) > 0)
{
base64_decode (plain, buf);
if (!(*plain & 0x80))
break;
pkttype = *plain & 0x40 ? (*plain & 0x3f) : ((*plain >> 2) & 0xf);
if (pkttype == CDK_PKT_COMPRESSED && r_zipalgo)
{
_gnutls_buffers_log ("armor compressed (algo=%d)\n",
*(plain + 1));
*r_zipalgo = *(plain + 1);
}
break;
}
}
return 0;
}
|
↓
|
_gnutls_openpgp_find_key
|
11
|
14
|
37
|
openpgp/pgp.c
|
cdk_packet_t
_gnutls_openpgp_find_key (cdk_kbnode_t knode, uint32_t keyid[2],
unsigned int priv)
{
cdk_kbnode_t p, ctx;
cdk_packet_t pkt;
uint32_t local_keyid[2];
ctx = NULL;
while ((p = cdk_kbnode_walk (knode, &ctx, 0)))
{
pkt = cdk_kbnode_get_packet (p);
if ((priv == 0
&& (pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY
|| pkt->pkttype == CDK_PKT_PUBLIC_KEY)) || (priv != 0
&& (pkt->pkttype ==
CDK_PKT_SECRET_SUBKEY
|| pkt->pkttype
==
CDK_PKT_SECRET_KEY)))
{
if (priv == 0)
cdk_pk_get_keyid (pkt->pkt.public_key, local_keyid);
else
cdk_pk_get_keyid (pkt->pkt.secret_key->pk, local_keyid);
if (local_keyid[0] == keyid[0] && local_keyid[1] == keyid[1])
{
return pkt;
}
}
}
gnutls_assert ();
return NULL;
}
|
↓
|
str_escape
|
11
|
12
|
25
|
x509/dn.c
|
static char *
str_escape (char *str, char *buffer, unsigned int buffer_size)
{
int str_length, j, i;
if (str == NULL || buffer == NULL)
return NULL;
str_length = MIN (strlen (str), buffer_size - 1);
for (i = j = 0; i < str_length; i++)
{
if (str[i] == ',' || str[i] == '+' || str[i] == '"'
|| str[i] == '\\' || str[i] == '<' || str[i] == '>'
|| str[i] == ';')
buffer[j++] = '\\';
buffer[j++] = str[i];
}
/* null terminate the string */
buffer[j] = 0;
return buffer;
}
|
↓
|
cdk_kbnode_find_next
|
11
|
12
|
21
|
opencdk/kbnode.c
|
cdk_kbnode_t
cdk_kbnode_find_next (cdk_kbnode_t node, cdk_packet_type_t pkttype)
{
for (node = node->next; node; node = node->next)
{
if (!pkttype)
return node;
else if (pkttype == CDK_PKT_USER_ID &&
(node->pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
node->pkt->pkttype == CDK_PKT_SECRET_KEY))
return NULL;
else if (pkttype == CDK_PKT_SIGNATURE &&
(node->pkt->pkttype == CDK_PKT_USER_ID ||
node->pkt->pkttype == CDK_PKT_PUBLIC_KEY ||
node->pkt->pkttype == CDK_PKT_SECRET_KEY))
return NULL;
else if (node->pkt->pkttype == pkttype)
return node;
}
return NULL;
}
|
|
_gnutls_fbase64_encode
|
10
|
61
|
98
|
x509_b64.c
|
|
_get_sk_dsa_raw
|
10
|
53
|
98
|
openpgp/privkey.c
|
|
_gnutls_fbase64_decode
|
10
|
50
|
92
|
x509_b64.c
|
|
_gnutls_x509_ext_gen_crl_dist_points
|
10
|
50
|
104
|
x509/extensions.c
|
|
gnutls_certificate_set_openpgp_key
|
10
|
48
|
86
|
openpgp/gnutls_openpgp.c
|
|
_decode_pkcs7_signed_data
|
10
|
47
|
94
|
x509/pkcs7.c
|
|
group_check_g_n
|
10
|
46
|
103
|
auth/srp.c
|
|
gnutls_x509_crq_get_extension_data
|
10
|
44
|
78
|
x509/crq.c
|
|
_gnutls_cipher_init
|
10
|
43
|
78
|
gnutls_cipher_int.c
|
|
cdk_pk_verify
|
10
|
42
|
66
|
opencdk/pubkey.c
|
|
gnutls_certificate_set_x509_key
|
10
|
42
|
79
|
gnutls_x509.c
|
|
gnutls_ocsp_req_add_cert
|
10
|
41
|
75
|
x509/ocsp.c
|
|
_gnutls_mpi_randomize
|
10
|
40
|
75
|
gnutls_mpi.c
|
|
proc_rsa_client_kx
|
10
|
38
|
102
|
auth/rsa.c
|
|
decode_ber_digest_info
|
10
|
37
|
72
|
gnutls_sig.c
|
|
_gnutls_x509_export_int_named
|
10
|
37
|
85
|
x509/common.c
|
|
gnutls_openpgp_get_key
|
10
|
35
|
63
|
openpgp/gnutls_openpgp.c
|
|
_pkcs1_rsa_verify_sig
|
10
|
35
|
74
|
gnutls_pubkey.c
|
|
_find_x509_cert
|
10
|
34
|
70
|
auth/cert.c
|
|
gnutls_pkcs7_set_crl_raw
|
10
|
32
|
72
|
x509/pkcs7.c
|
|
_gnutls_get_public_rsa_params
|
10
|
32
|
69
|
auth/rsa.c
|
|
_cdk_hash_pubkey
|
10
|
31
|
43
|
opencdk/sig-check.c
|
|
_gnutls_send_finished
|
10
|
30
|
69
|
gnutls_handshake.c
|
|
ecc_sign_hash
|
10
|
30
|
69
|
nettle/ecc_sign_hash.c
|
|
gnutls_x509_crt_get_authority_info_access
|
10
|
29
|
56
|
x509/x509.c
|
|
_gnutls_ext_init
|
10
|
29
|
46
|
gnutls_extensions.c
|
|
cdk_keydb_idx_rebuild
|
10
|
29
|
47
|
opencdk/keydb.c
|
|
cdk_stream_write
|
10
|
29
|
55
|
opencdk/stream.c
|
|
sign_tls_hash
|
10
|
28
|
65
|
gnutls_sig.c
|
|
_gnutls_cert_type_send_params
|
10
|
28
|
66
|
ext/cert_type.c
|
|
uid_list_add_sig
|
10
|
26
|
50
|
opencdk/sig-check.c
|
|
write_pubkey_enc
|
10
|
25
|
34
|
opencdk/write-packet.c
|
|
register_x86_crypto
|
10
|
25
|
64
|
accelerated/x86/aes-x86.c
|
|
write_onepass_sig
|
10
|
23
|
31
|
opencdk/write-packet.c
|
|
_gnutls_auth_cipher_encrypt2_tag
|
10
|
23
|
42
|
gnutls_cipher_int.c
|
|
write_head_old
|
10
|
23
|
34
|
opencdk/write-packet.c
|
|
cdk_kbnode_move
|
10
|
22
|
28
|
opencdk/kbnode.c
|
|
cdk_pk_get_keyid
|
10
|
20
|
36
|
opencdk/pubkey.c
|
|
_gnutls_check_key_usage
|
10
|
18
|
52
|
gnutls_x509.c
|
|
_gnutls_pubkey_compatible_with_sig
|
10
|
16
|
37
|
gnutls_pubkey.c
|
|
_gnutls_handshake_io_recv_int
|
10
|
14
|
36
|
gnutls_buffers.c
|
|
cdk_armor_encode_buffer
|
9
|
62
|
89
|
opencdk/armor.c
|
|
_gnutls_read_server_hello
|
9
|
50
|
106
|
gnutls_handshake.c
|
|
gnutls_pkcs12_verify_mac
|
9
|
48
|
101
|
x509/pkcs12.c
|
|
session_ticket_recv_params
|
9
|
48
|
90
|
ext/session_ticket.c
|
|
proc_dhe_server_kx
|
9
|
47
|
84
|
auth/dhe.c
|
|
read_pbkdf2_params
|
9
|
47
|
109
|
x509/privkey_pkcs8.c
|
|
_gnutls_x509_der_encode
|
9
|
46
|
82
|
x509/common.c
|
|
_gnutls_handshake_verify_data
|
9
|
46
|
90
|
gnutls_sig.c
|
|
_get_pk_dsa_raw
|
9
|
46
|
88
|
openpgp/pgp.c
|
|
unpack_certificate_auth_info
|
9
|
45
|
79
|
gnutls_session_pack.c
|
|
write_pbkdf2_params
|
9
|
45
|
105
|
x509/privkey_pkcs8.c
|
|
keydb_idx_build
|
9
|
44
|
71
|
opencdk/keydb.c
|
|
_gnutls_handshake_verify_cert_vrfy
|
9
|
42
|
91
|
gnutls_sig.c
|
|
ecc_make_key_ex
|
9
|
42
|
82
|
nettle/ecc_make_key.c
|
|
get_subject_alt_name
|
9
|
42
|
81
|
x509/crq.c
|
|
_decode_pkcs12_auth_safe
|
9
|
40
|
80
|
x509/pkcs12.c
|
|
gnutls_x509_crt_set_key_purpose_oid
|
9
|
40
|
90
|
x509/x509_write.c
|
|
gnutls_pubkey_import
|
9
|
39
|
81
|
gnutls_pubkey.c
|
|
get_extension_oid
|
9
|
39
|
83
|
x509/extensions.c
|
|
_gnutls_gen_cert_client_cert_vrfy
|
9
|
39
|
81
|
auth/cert.c
|
|
_gnutls_epoch_set_keys
|
9
|
38
|
57
|
gnutls_constate.c
|
|
_gnutls_sbase64_decode
|
9
|
38
|
59
|
auth/srp_sb64.c
|
|
gnutls_ocsp_resp_verify_direct
|
9
|
38
|
71
|
x509/ocsp.c
|
|
decode_private_key_info
|
9
|
37
|
77
|
x509/privkey_pkcs8.c
|
|
P_hash
|
9
|
36
|
76
|
gnutls_state.c
|
|
read_cas_url
|
9
|
36
|
72
|
gnutls_x509.c
|
|
gnutls_global_init
|
9
|
36
|
76
|
gnutls_global.c
|
|
gnutls_pkcs11_token_set_pin
|
9
|
34
|
66
|
pkcs11_write.c
|
|
set_extension
|
9
|
34
|
81
|
x509/extensions.c
|
|
_gnutls_stream_read
|
9
|
34
|
75
|
gnutls_buffers.c
|
|
_gnutls_server_select_comp_method
|
9
|
33
|
66
|
gnutls_handshake.c
|
|
add_extension
|
9
|
33
|
62
|
x509/extensions.c
|
|
gnutls_pkcs11_privkey_import_url
|
9
|
33
|
59
|
pkcs11_privkey.c
|
|
check_if_same_cert
|
9
|
30
|
58
|
x509/verify.c
|
|
do_encode_md
|
9
|
30
|
42
|
opencdk/seskey.c
|
|
_gnutls_openpgp_export
|
9
|
30
|
63
|
openpgp/pgp.c
|
|
_gnutls_openpgp_verify_key
|
9
|
29
|
61
|
openpgp/compat.c
|
|
gnutls_certificate_set_openpgp_key_file2
|
9
|
28
|
56
|
openpgp/gnutls_openpgp.c
|
|
gnutls_x509_trust_list_add_crls
|
9
|
28
|
58
|
x509/verify-high.c
|
|
gnutls_psk_set_client_credentials
|
9
|
27
|
56
|
gnutls_psk.c
|
|
_gnutls_max_record_recv_params
|
9
|
27
|
66
|
ext/max_record.c
|
|
gnutls_openpgp_keyring_get_crt
|
9
|
27
|
47
|
openpgp/extras.c
|
|
cdk_keydb_check_sk
|
9
|
27
|
46
|
opencdk/keydb.c
|
|
gnutls_x509_trust_list_verify_named_crt
|
9
|
26
|
55
|
x509/verify-high.c
|
|
do_device_source_egd
|
9
|
26
|
54
|
nettle/rnd.c
|
|
_gnutls_buffer_append_data
|
9
|
26
|
49
|
gnutls_str.c
|
|
base64_encode
|
9
|
23
|
35
|
opencdk/armor.c
|
|
ecc_shared_secret
|
9
|
22
|
46
|
nettle/ecc_shared_secret.c
|
|
cdk_stream_flush
|
9
|
22
|
38
|
opencdk/stream.c
|
|
_cdk_pkt_read_len
|
9
|
21
|
31
|
opencdk/read-packet.c
|
|
_gnutls_openpgp_find_subkey_idx
|
9
|
18
|
37
|
openpgp/pgp.c
|
|
_gnutls_openpgp_request_key
|
9
|
18
|
44
|
openpgp/gnutls_openpgp.c
|
|
_gnutls_send_client_certificate
|
9
|
18
|
58
|
gnutls_kx.c
|
|
cdk_pk_to_fingerprint
|
9
|
16
|
31
|
opencdk/pubkey.c
|
|
store_session
|
9
|
16
|
37
|
gnutls_db.c
|
|
_gnutls_recv_int
|
9
|
16
|
40
|
gnutls_record.c
|
|
_gnutls_session_pack
|
9
|
42
|
87
|
gnutls_session_pack.c
|
|
write_schema_params
|
9
|
35
|
87
|
x509/privkey_pkcs8.c
|
|
_gnutls_dh_set_group
|
9
|
36
|
71
|
gnutls_state.c
|
|
_gnutls_handshake_common
|
9
|
24
|
67
|
gnutls_handshake.c
|
|
gnutls_pkcs11_privkey_generate
|
9
|
114
|
175
|
pkcs11_privkey.c
|
|
print_key_info
|
9
|
45
|
90
|
openpgp/output.c
|
|
find_by_keyid
|
9
|
16
|
34
|
opencdk/keydb.c
|
|
gnutls_x509_crq_set_subject_alt_name
|
8
|
36
|
87
|
x509/crq.c
|
|
calc_enc_length
|
8
|
23
|
55
|
gnutls_cipher.c
|
|
ip_to_string
|
8
|
16
|
40
|
x509/output.c
|
|
gnutls_priority_set
|
8
|
9
|
29
|
gnutls_priority.c
|
|
_gnutls_srp_entry_free
|
8
|
8
|
20
|
auth/srp_passwd.c
|
|
_gnutls_send_new_session_ticket
|
8
|
53
|
93
|
ext/session_ticket.c
|
|
pwd_put_values
|
8
|
49
|
85
|
auth/srp_passwd.c
|
|
_gnutls_pkcs7_decrypt_data
|
8
|
48
|
102
|
x509/privkey_pkcs8.c
|
|
encode_to_pkcs8_key
|
8
|
45
|
95
|
x509/privkey_pkcs8.c
|
|
encode_ber_digest_info
|
8
|
44
|
83
|
gnutls_sig.c
|
|
read_pbe_enc_params
|
8
|
42
|
86
|
x509/privkey_pkcs8.c
|
|
encrypt_data
|
8
|
41
|
71
|
x509/privkey_pkcs8.c
|
|
_gnutls_proc_cert_client_cert_vrfy
|
8
|
41
|
75
|
auth/cert.c
|
|
gnutls_x509_privkey_import_dsa_raw
|
8
|
39
|
74
|
x509/privkey.c
|
|
read_cert_url
|
8
|
38
|
68
|
gnutls_x509.c
|
|
gnutls_x509_crt_get_pk_dsa_raw
|
8
|
38
|
76
|
x509/x509.c
|
|
literal_encode
|
8
|
38
|
51
|
opencdk/literal.c
|
|
decrypt_ticket
|
8
|
38
|
69
|
ext/session_ticket.c
|
|
_gnutls_gen_dh_common_client_kx_int
|
8
|
37
|
76
|
auth/dh_common.c
|
|
_gnutls_PRF
|
8
|
36
|
80
|
gnutls_state.c
|
|
_gnutls_gen_rsa_client_kx
|
8
|
36
|
83
|
auth/rsa.c
|
|
gnutls_pkcs12_get_bag
|
8
|
35
|
75
|
x509/pkcs12.c
|
|
_gnutls_x509_read_value
|
8
|
34
|
63
|
x509/common.c
|
|
_gnutls_io_write_flush
|
8
|
34
|
66
|
gnutls_buffers.c
|
|
decode_dsa_key
|
8
|
34
|
68
|
x509/privkey.c
|
|
cdk_keydb_get_pk
|
8
|
34
|
53
|
opencdk/keydb.c
|
|
gnutls_pubkey_import_openpgp
|
8
|
33
|
58
|
gnutls_pubkey.c
|
|
set_attribute
|
8
|
32
|
77
|
x509/crq.c
|
|
gnutls_pkcs12_import
|
8
|
31
|
61
|
x509/pkcs12.c
|
|
_gnutls_x509_ext_gen_proxyCertInfo
|
8
|
31
|
64
|
x509/extensions.c
|
|
_gnutls_x509_set_dn_oid
|
8
|
30
|
75
|
x509/dn.c
|
|
gnutls_pkcs7_get_crl_raw
|
8
|
30
|
61
|
x509/pkcs7.c
|
|
_gnutls_x509_ext_gen_basicConstraints
|
8
|
30
|
58
|
x509/extensions.c
|
|
gnutls_x509_crq_privkey_sign
|
8
|
30
|
72
|
x509/crq.c
|
|
_gnutls_client_set_ciphersuite
|
8
|
30
|
78
|
gnutls_handshake.c
|
|
read_key_url
|
8
|
29
|
58
|
gnutls_x509.c
|
|
gnutls_server_name_set
|
8
|
29
|
57
|
ext/server_name.c
|
|
_gnutls_x509_read_uint
|
8
|
29
|
49
|
x509/mpi.c
|
|
gnutls_x509_crq_import
|
8
|
29
|
59
|
x509/crq.c
|
|
gnutls_x509_crl_import
|
8
|
29
|
58
|
x509/crl.c
|
|
_gnutls_supported_ecc_recv_params
|
8
|
28
|
65
|
ext/ecc.c
|
|
_pkcs11_compat_init
|
8
|
28
|
45
|
pkcs11.c
|
|
_randomize_pwd_entry
|
8
|
28
|
52
|
auth/srp_passwd.c
|
|
gnutls_pkcs7_import
|
8
|
28
|
55
|
x509/pkcs7.c
|
|
gnutls_x509_crt_set_subject_alt_name
|
8
|
27
|
65
|
x509/x509_write.c
|
|
_gnutls_encrypt
|
8
|
26
|
58
|
gnutls_cipher.c
|
|
_gnutls_x509_ext_extract_basicConstraints
|
8
|
26
|
52
|
x509/extensions.c
|
|
print_key_times
|
8
|
26
|
49
|
openpgp/output.c
|
|
gnutls_certificate_set_key
|
8
|
26
|
54
|
gnutls_x509.c
|
|
_gnutls_mpi_dprint_size
|
8
|
25
|
39
|
gnutls_mpi.c
|
|
_gnutls_cryptodev_init
|
8
|
25
|
54
|
accelerated/cryptodev.c
|
|
_gnutls_decrypt
|
8
|
25
|
53
|
gnutls_cipher.c
|
|
read_mpi
|
8
|
25
|
40
|
opencdk/read-packet.c
|
|
gnutls_calc_dh_secret
|
8
|
24
|
44
|
gnutls_dh.c
|
|
check_if_sorted
|
8
|
24
|
45
|
x509/x509.c
|
|
_gnutls_x509_ext_gen_subject_alt_name
|
8
|
23
|
53
|
x509/extensions.c
|
|
pkcs11_find_slot
|
8
|
23
|
48
|
pkcs11.c
|
|
_gnutls_record_overhead_rt
|
8
|
23
|
41
|
gnutls_state.c
|
|
_gnutls_auth_cipher_init
|
8
|
23
|
48
|
gnutls_cipher_int.c
|
|
_gnutls_send_client_certificate_verify
|
8
|
22
|
54
|
gnutls_kx.c
|
|
_cdk_digest_encode_pkcs1
|
8
|
22
|
37
|
opencdk/seskey.c
|
|
_gnutls_epoch_gc
|
8
|
21
|
33
|
gnutls_constate.c
|
|
write_user_id
|
8
|
19
|
34
|
opencdk/write-packet.c
|
|
_gnutls_ext_sr_finished
|
8
|
19
|
45
|
ext/safe_renegotiation.c
|
|
print_key_usage
|
8
|
19
|
31
|
openpgp/output.c
|
|
pwd_read_conf
|
8
|
19
|
39
|
auth/srp_passwd.c
|
|
_gnutls_buffer_resize
|
8
|
19
|
37
|
gnutls_str.c
|
|
mktime_utc
|
8
|
18
|
27
|
x509/common.c
|
|
gnutls_pkcs12_bag_set_data
|
8
|
18
|
50
|
x509/pkcs12_bag.c
|
|
_cdk_keydb_open
|
8
|
17
|
38
|
opencdk/keydb.c
|
|
cdk_stream_kick_off
|
8
|
17
|
29
|
opencdk/stream.c
|
|
read_s2k
|
8
|
16
|
29
|
opencdk/read-packet.c
|
|
_gnutls_recv_client_certificate_verify_message
|
8
|
16
|
41
|
gnutls_kx.c
|
|
cdk_s2k_new
|
8
|
16
|
25
|
opencdk/seskey.c
|
|
key_usage_to_cdk_usage
|
8
|
16
|
22
|
opencdk/keydb.c
|
|
_gnutls_buffer_hexdump
|
8
|
15
|
24
|
gnutls_str.c
|
|
_cdk_pubkey_compare
|
8
|
15
|
22
|
opencdk/new-packet.c
|
|
find_by_fpr
|
8
|
13
|
25
|
opencdk/keydb.c
|
|
keydb_check_key
|
8
|
13
|
25
|
opencdk/keydb.c
|
|
wrap_nettle_cipher_setkey
|
8
|
35
|
72
|
nettle/cipher.c
|
|
keydb_cache_find
|
8
|
18
|
36
|
opencdk/keydb.c
|
|
_gnutls_free_auth_info
|
8
|
39
|
74
|
gnutls_auth.c
|
|
gnutls_bye
|
8
|
28
|
59
|
gnutls_record.c
|
|
_gnutls_handshake_sign_data
|
8
|
50
|
102
|
gnutls_sig.c
|
|
_encode_privkey
|
8
|
39
|
79
|
x509/privkey_pkcs8.c
|
|
_gnutls_x509_verify_algorithm
|
8
|
31
|
71
|
x509/verify.c
|
|
verify_tls_hash
|
8
|
29
|
67
|
gnutls_sig.c
|
|
_gnutls_recv_handshake_final
|
8
|
27
|
54
|
gnutls_handshake.c
|
|
gnutls_dh_get_group
|
7
|
32
|
52
|
gnutls_ui.c
|
|
_gnutls_dh_set_peer_public
|
7
|
29
|
56
|
gnutls_state.c
|
|
_gnutls_send_handshake_final
|
7
|
25
|
57
|
gnutls_handshake.c
|
|
_gnutls_openpgp_privkey_get_mpis
|
7
|
31
|
67
|
openpgp/privkey.c
|
|
_cdk_check_args
|
7
|
8
|
13
|
opencdk/misc.c
|
|
gnutls_pkcs11_copy_secret_key
|
7
|
65
|
106
|
pkcs11_secret.c
|
|
proc_rsa_export_server_kx
|
7
|
51
|
93
|
auth/rsa_export.c
|
|
gnutls_init
|
7
|
50
|
104
|
gnutls_state.c
|
|
check_intel_or_amd
|
7
|
5
|
17
|
accelerated/x86/aes-x86.c
|
|
gnutls_x509_dn_get_rdn_ava
|
7
|
46
|
80
|
x509/x509.c
|
|
parse_der_cert_mem
|
7
|
39
|
68
|
gnutls_x509.c
|
|
_gnutls_parse_extensions
|
7
|
39
|
76
|
gnutls_extensions.c
|
|
_gnutls_calc_srp_S2
|
7
|
36
|
55
|
gnutls_srp.c
|
|
_gnutls_dgram_read
|
7
|
36
|
71
|
gnutls_buffers.c
|
|
_gnutls_x509_pkix_sign
|
7
|
35
|
83
|
x509/sign.c
|
|
_gnutls_proc_srp_client_kx
|
7
|
35
|
69
|
auth/srp.c
|
|
pwd_put_values2
|
7
|
35
|
60
|
auth/srp_passwd.c
|
|
gnutls_x509_privkey_export_dsa_raw
|
7
|
35
|
68
|
x509/privkey.c
|
|
gnutls_pkcs12_bag_encrypt
|
7
|
34
|
77
|
x509/pkcs12_bag.c
|
|
_gnutls_x509_encode_and_copy_PKI_params
|
7
|
34
|
71
|
x509/common.c
|
|
_get_pk_rsa_raw
|
7
|
33
|
62
|
openpgp/pgp.c
|
|
_gnutls_hmac_init
|
7
|
32
|
58
|
gnutls_hash_int.c
|
|
_wrap_nettle_pk_derive
|
7
|
32
|
65
|
nettle/pk.c
|
|
_decode_pkcs8_dsa_key
|
7
|
32
|
64
|
x509/privkey_pkcs8.c
|
|
_gnutls_get_asn_mpis
|
7
|
31
|
73
|
x509/mpi.c
|
|
gnutls_pcert_import_x509
|
7
|
31
|
56
|
gnutls_pcert.c
|
|
gnutls_pcert_import_openpgp
|
7
|
31
|
56
|
gnutls_pcert.c
|
|
_gnutls_ssl3_finished
|
7
|
31
|
58
|
gnutls_handshake.c
|
|
pkcs11_add_module
|
7
|
31
|
67
|
pkcs11.c
|
|
gnutls_pubkey_get_pk_dsa_raw
|
7
|
30
|
61
|
gnutls_pubkey.c
|
|
_gnutls_x509_write_ecc_params
|
7
|
30
|
58
|
x509/key_encode.c
|
|
_gnutls_x509_write_dsa_params
|
7
|
30
|
59
|
x509/key_encode.c
|
|
_gnutls_sbase64_encode
|
7
|
30
|
52
|
auth/srp_sb64.c
|
|
_cdk_trim_string
|
7
|
3
|
10
|
opencdk/misc.c
|
|
_gnutls_x509_write_value
|
7
|
29
|
60
|
x509/common.c
|
|
cdk_stream_new
|
7
|
28
|
44
|
opencdk/stream.c
|
|
gnutls_pcert_list_import_x509_raw
|
7
|
28
|
46
|
gnutls_pcert.c
|
|
gnutls_x509_crl_get_extension_info
|
7
|
27
|
52
|
x509/crl.c
|
|
gnutls_ocsp_req_get_nonce
|
7
|
27
|
53
|
x509/ocsp.c
|
|
_gnutls_x509_write_int
|
7
|
27
|
51
|
gnutls_mpi.c
|
|
print_aki
|
7
|
27
|
53
|
x509/output.c
|
|
gnutls_x509_crt_get_extension_info
|
7
|
27
|
52
|
x509/x509.c
|
|
gnutls_credentials_set
|
7
|
26
|
58
|
gnutls_auth.c
|
|
gnutls_certificate_set_x509_trust
|
7
|
26
|
46
|
gnutls_x509.c
|
|
pkcs11_open_session
|
7
|
25
|
44
|
pkcs11.c
|
|
gnutls_privkey_import_openpgp
|
7
|
25
|
52
|
gnutls_privkey.c
|
|
_gnutls_finished
|
7
|
25
|
49
|
gnutls_handshake.c
|
|
_gnutls_selected_cert_supported_kx
|
7
|
25
|
47
|
gnutls_cert.c
|
|
_gnutls_copy_ciphersuites
|
7
|
25
|
48
|
gnutls_handshake.c
|
|
wrap_nettle_mpi_scan
|
7
|
25
|
53
|
nettle/mpi.c
|
|
gen_psk_client_kx
|
7
|
24
|
48
|
auth/dhe_psk.c
|
|
_algo_register
|
7
|
24
|
48
|
crypto-backend.c
|
|
shorten_clist
|
7
|
24
|
58
|
x509/verify-high.c
|
|
alloc_and_load_x509_certs
|
7
|
24
|
37
|
auth/cert.c
|
|
_gnutls_openpgp_crt_verify_peers
|
7
|
23
|
53
|
gnutls_cert.c
|
|
_gnutls_ecdh_common_print_server_kx
|
7
|
23
|
40
|
auth/ecdh_common.c
|
|
_cdk_copy_seckey
|
7
|
22
|
33
|
opencdk/new-packet.c
|
|
wrap_nettle_mpi_print
|
7
|
22
|
47
|
nettle/mpi.c
|
|
keydb_idx_parse
|
7
|
22
|
34
|
opencdk/keydb.c
|
|
decode
|
7
|
22
|
31
|
x509_b64.c
|
|
gnutls_x509_crt_check_hostname
|
7
|
21
|
65
|
x509/rfc2818_hostname.c
|
|
_cdk_hash_userid
|
7
|
21
|
27
|
opencdk/sig-check.c
|
|
gnutls_x509_trust_list_deinit
|
7
|
21
|
27
|
x509/verify-high.c
|
|
gnutls_x509_crt_sign2
|
7
|
20
|
42
|
x509/x509_write.c
|
|
gnutls_srp_set_server_credentials_file
|
7
|
20
|
43
|
gnutls_srp.c
|
|
_gnutls_auth_info_set
|
7
|
20
|
59
|
gnutls_auth.c
|
|
get_issuers_num
|
7
|
20
|
45
|
auth/cert.c
|
|
gnutls_x509_crt_get_extension_by_oid
|
7
|
20
|
46
|
x509/x509.c
|
|
_gnutls_max_record_send_params
|
7
|
20
|
51
|
ext/max_record.c
|
|
gnutls_x509_crl_get_number
|
7
|
19
|
44
|
x509/crl.c
|
|
idx_init
|
7
|
19
|
43
|
opencdk/keydb.c
|
|
_gnutls_recv_server_kx_message
|
7
|
19
|
48
|
gnutls_kx.c
|
|
cdk_pk_get_fingerprint
|
7
|
19
|
28
|
opencdk/pubkey.c
|
|
_cdk_copy_pubkey
|
7
|
19
|
24
|
opencdk/new-packet.c
|
|
_gnutls_session_get_sign_algo
|
7
|
19
|
38
|
ext/signature.c
|
|
gnutls_x509_crt_get_basic_constraints
|
7
|
19
|
45
|
x509/x509.c
|
|
mpi_to_buffer
|
7
|
18
|
33
|
opencdk/pubkey.c
|
|
_gnutls_supported_ecc_pf_recv_params
|
7
|
18
|
34
|
ext/ecc.c
|
|
do_trivia_source
|
7
|
18
|
55
|
nettle/rnd.c
|
|
_gnutls_record_buffer_get
|
7
|
17
|
32
|
gnutls_buffers.c
|
|
do_device_source
|
7
|
17
|
43
|
nettle/rnd.c
|
|
_gnutls_pkcs_flags_to_schema
|
7
|
17
|
28
|
x509/privkey_pkcs8.c
|
|
cdk_kbnode_read_from_mem
|
7
|
17
|
28
|
opencdk/kbnode.c
|
|
read_user_id
|
7
|
16
|
23
|
opencdk/read-packet.c
|
|
_gnutls_epoch_set_cipher_suite
|
7
|
16
|
30
|
gnutls_constate.c
|
|
_gnutls_supported_compression_methods
|
7
|
16
|
35
|
gnutls_compress.c
|
|
gnutls_pubkey_get_openpgp_key_id
|
7
|
15
|
32
|
gnutls_pubkey.c
|
|
sig_to_datum
|
7
|
15
|
26
|
opencdk/pubkey.c
|
|
do_read
|
7
|
14
|
22
|
nettle/egd.c
|
|
_gnutls_buffer_escape
|
7
|
14
|
36
|
gnutls_str.c
|
|
gnutls_cipher_suite_info
|
7
|
13
|
24
|
algorithms/ciphersuites.c
|
|
_gnutls_x509_san_find_type
|
7
|
13
|
17
|
x509/common.c
|
|
gnutls_certificate_set_x509_key_mem
|
7
|
12
|
27
|
gnutls_x509.c
|
|
_gnutls_ext_restore_resumed_session
|
7
|
12
|
41
|
gnutls_extensions.c
|
|
cpydata
|
7
|
12
|
19
|
x509_b64.c
|
|
keydb_find_bykeyid
|
7
|
12
|
17
|
opencdk/keydb.c
|
|
_gnutls_send_handshake
|
7
|
37
|
96
|
gnutls_handshake.c
|
|
write_new_general_name
|
6
|
33
|
65
|
x509/extensions.c
|
|
cdk_kbnode_hash
|
6
|
20
|
47
|
opencdk/kbnode.c
|
|
cipher_to_pkcs_params
|
6
|
18
|
30
|
x509/privkey_pkcs8.c
|
|
encode
|
6
|
45
|
84
|
auth/srp_sb64.c
|
|
_gnutls_openpgp_crt_get_mpis
|
6
|
28
|
55
|
openpgp/pgp.c
|
|
_gnutls_proc_certificate
|
6
|
17
|
42
|
auth/cert.c
|
|
add_key_usage
|
6
|
9
|
21
|
opencdk/keydb.c
|
|
check_buffers
|
6
|
8
|
22
|
gnutls_record.c
|
|
check_phe_partial
|
6
|
7
|
17
|
accelerated/x86/aes-padlock.c
|
|
is_selfsig
|
6
|
7
|
14
|
opencdk/keydb.c
|
|
gnutls_session_is_resumed
|
6
|
6
|
22
|
gnutls_state.c
|
|
_gnutls_proc_dh_common_server_kx
|
6
|
49
|
82
|
auth/dh_common.c
|
|
_gnutls_recv_new_session_ticket
|
6
|
45
|
71
|
ext/session_ticket.c
|
|
encrypt_ticket
|
6
|
45
|
73
|
ext/session_ticket.c
|
|
_gnutls_send_server_hello
|
6
|
41
|
79
|
gnutls_handshake.c
|
|
_cdk_hash_sig_data
|
6
|
41
|
59
|
opencdk/sig-check.c
|
|
proc_psk_client_kx
|
6
|
40
|
78
|
auth/dhe_psk.c
|
|
_gnutls_calc_srp_B
|
6
|
37
|
68
|
gnutls_srp.c
|
|
_gnutls_mpi_log
|
6
|
36
|
62
|
gnutls_errors.c
|
|
gnutls_dtls_cookie_send
|
6
|
34
|
83
|
gnutls_dtls.c
|
|
proc_srp_cert_server_kx
|
6
|
33
|
64
|
auth/srp_rsa.c
|
|
gnutls_x509_crq_verify
|
6
|
32
|
61
|
x509/crq.c
|
|
_gnutls_proc_psk_client_kx
|
6
|
32
|
66
|
auth/psk.c
|
|
gnutls_x509_crl_get_raw_issuer_dn
|
6
|
31
|
67
|
x509/crl.c
|
|
_gnutls_proc_dh_common_client_kx
|
6
|
31
|
66
|
auth/dh_common.c
|
|
_gnutls_x509_time2gtime
|
6
|
31
|
63
|
x509/common.c
|
|
transmit_message
|
6
|
31
|
77
|
gnutls_dtls.c
|
|
_gnutls_x509_read_ecc_params
|
6
|
31
|
60
|
x509/key_decode.c
|
|
gnutls_pubkey_import_dsa_raw
|
6
|
31
|
58
|
gnutls_pubkey.c
|
|
create_empty_signed_data
|
6
|
30
|
75
|
x509/pkcs7.c
|
|
wrap_padlock_hmac_fast
|
6
|
30
|
59
|
accelerated/x86/hmac-padlock.c
|
|
_gnutls_gen_supplemental
|
6
|
30
|
55
|
gnutls_supplemental.c
|
|
IS_SHA
|
6
|
3
|
8
|
gnutls_hash_int.h
|
|
_gnutls_calc_srp_u
|
6
|
29
|
52
|
gnutls_srp.c
|
|
_gnutls_recv_hello_verify_request
|
6
|
28
|
57
|
gnutls_handshake.c
|
|
write_pbe_enc_params
|
6
|
28
|
65
|
x509/privkey_pkcs8.c
|
|
_gnutls_openpgp_privkey_decrypt_data
|
6
|
28
|
62
|
openpgp/privkey.c
|
|
_gnutls_x509_decode_octet_string
|
6
|
27
|
52
|
x509/common.c
|
|
gnutls_x509_privkey_import_ecc_raw
|
6
|
27
|
54
|
x509/privkey.c
|
|
gen_srp_cert_server_kx
|
6
|
27
|
55
|
auth/srp_rsa.c
|
|
gen_psk_server_kx
|
6
|
27
|
49
|
auth/dhe_psk.c
|
|
_gnutls_x509_read_dsa_params
|
6
|
27
|
62
|
x509/key_decode.c
|
|
gnutls_x509_crq_get_key_rsa_raw
|
6
|
26
|
50
|
x509/crq.c
|
|
_gnutls_x509_write_rsa_pubkey
|
6
|
26
|
53
|
x509/key_encode.c
|
|
cdk_stream_create
|
6
|
26
|
40
|
opencdk/stream.c
|
|
_rndegd_connect_socket
|
6
|
26
|
47
|
nettle/egd.c
|
|
_cdk_stream_open_mode
|
6
|
25
|
40
|
opencdk/stream.c
|
|
gnutls_x509_privkey_export_pkcs8
|
6
|
25
|
64
|
x509/privkey_pkcs8.c
|
|
gnutls_x509_crt_get_pk_rsa_raw
|
6
|
25
|
48
|
x509/x509.c
|
|
cdk_keydb_get_sk
|
6
|
25
|
44
|
opencdk/keydb.c
|
|
gnutls_pkcs7_delete_crl
|
6
|
24
|
51
|
x509/pkcs7.c
|
|
gnutls_pkcs7_delete_crt
|
6
|
24
|
51
|
x509/pkcs7.c
|
|
_gnutls_x509_get_time
|
6
|
24
|
48
|
x509/common.c
|
|
print_proxy
|
6
|
23
|
36
|
x509/output.c
|
|
pwd_put_values
|
6
|
23
|
46
|
auth/psk_passwd.c
|
|
gnutls_x509_crl_set_number
|
6
|
23
|
50
|
x509/crl_write.c
|
|
gnutls_x509_crl_set_authority_key_id
|
6
|
23
|
50
|
x509/crl_write.c
|
|
gnutls_x509_crl_get_signature
|
6
|
23
|
45
|
x509/crl.c
|
|
gnutls_pcert_import_openpgp_raw
|
6
|
23
|
47
|
gnutls_pcert.c
|
|
gnutls_server_name_get
|
6
|
23
|
52
|
ext/server_name.c
|
|
_gnutls_x509_write_sig_params
|
6
|
23
|
51
|
x509/mpi.c
|
|
gnutls_certificate_set_x509_crl
|
6
|
23
|
40
|
gnutls_x509.c
|
|
gnutls_x509_crt_set_authority_key_id
|
6
|
23
|
50
|
x509/x509_write.c
|
|
gnutls_x509_crt_set_subject_key_id
|
6
|
23
|
50
|
x509/x509_write.c
|
|
_gnutls_gen_x509_crt
|
6
|
22
|
51
|
auth/cert.c
|
|
_gnutls_srp_recv_params
|
6
|
22
|
43
|
ext/srp.c
|
|
gnutls_x509_crt_get_signature
|
6
|
22
|
44
|
x509/x509.c
|
|
do_device_source
|
6
|
22
|
47
|
nettle/rnd.c
|
|
_gnutls_dh_common_print_server_kx
|
6
|
22
|
45
|
auth/dh_common.c
|
|
_gnutls_gen_psk_client_kx
|
6
|
22
|
43
|
auth/psk.c
|
|
record_read_headers
|
6
|
21
|
71
|
gnutls_record.c
|
|
gnutls_openpgp_count_key_names
|
6
|
21
|
33
|
openpgp/gnutls_openpgp.c
|
|
_gnutls_bin2hex
|
6
|
21
|
34
|
gnutls_str.c
|
|
hash_encode
|
6
|
21
|
39
|
opencdk/hash.c
|
|
gnutls_x509_crl_set_crt_serial
|
6
|
21
|
53
|
x509/crl_write.c
|
|
get_x509_name
|
6
|
21
|
36
|
gnutls_x509.c
|
|
_gnutls_ext_sr_recv_cs
|
6
|
21
|
42
|
ext/safe_renegotiation.c
|
|
cdk_stream_set_literal_flag
|
6
|
21
|
33
|
opencdk/stream.c
|
|
gnutls_x509_crl_sign2
|
6
|
20
|
42
|
x509/crl_write.c
|
|
_gnutls_get_private_rsa_params
|
6
|
20
|
50
|
auth/rsa_export.c
|
|
gnutls_openpgp_keyring_get_crt_count
|
6
|
20
|
36
|
openpgp/extras.c
|
|
_gnutls_epoch_alloc
|
6
|
19
|
34
|
gnutls_constate.c
|
|
_gnutls_rsa_export_set_pubkey
|
6
|
19
|
34
|
gnutls_state.c
|
|
gnutls_session_ticket_enable_server
|
6
|
19
|
38
|
ext/session_ticket.c
|
|
_gnutls_ext_sr_send_cs
|
6
|
19
|
39
|
ext/safe_renegotiation.c
|
|
_gnutls_send_server_kx_message
|
6
|
19
|
42
|
gnutls_kx.c
|
|
cdk_stream_new_from_cbs
|
6
|
19
|
34
|
opencdk/stream.c
|
|
gnutls_ocsp_resp_get_responder
|
6
|
19
|
42
|
x509/ocsp.c
|
|
gnutls_openpgp_crt_import
|
6
|
18
|
35
|
openpgp/pgp.c
|
|
gnutls_sec_param_to_pk_bits
|
6
|
18
|
36
|
algorithms/secparams.c
|
|
_gnutls_write_connection_state_init
|
6
|
18
|
44
|
gnutls_constate.c
|
|
_gnutls_peers_cert_less_512
|
6
|
18
|
40
|
auth/rsa_export.c
|
|
_gnutls_session_sign_algo_enabled
|
6
|
18
|
38
|
ext/signature.c
|
|
gnutls_openpgp_privkey_import
|
6
|
18
|
37
|
openpgp/privkey.c
|
|
_gnutls_supported_ecc_send_params
|
6
|
18
|
38
|
ext/ecc.c
|
|
gnutls_x509_crt_get_key_usage
|
6
|
18
|
42
|
x509/x509.c
|
|
oid2cipher
|
6
|
18
|
35
|
x509/privkey_pkcs8.c
|
|
gnutls_x509_privkey_cpy
|
6
|
17
|
29
|
x509/privkey.c
|
|
_cdk_subpkt_copy
|
6
|
17
|
26
|
opencdk/new-packet.c
|
|
pkcs11_url_to_info
|
6
|
17
|
32
|
pkcs11.c
|
|
gnutls_certificate_set_openpgp_keyring_mem
|
6
|
17
|
35
|
openpgp/gnutls_openpgp.c
|
|
_gnutls_read_connection_state_init
|
6
|
17
|
43
|
gnutls_constate.c
|
|
gnutls_openpgp_privkey_get_subkey_pk_algorithm
|
6
|
17
|
32
|
openpgp/privkey.c
|
|
_gnutls_pk_params_copy
|
6
|
17
|
25
|
gnutls_pk.c
|
|
_gnutls_get_cred
|
6
|
17
|
30
|
gnutls_auth.c
|
|
_gnutls_mpi_dprint
|
6
|
17
|
27
|
gnutls_mpi.c
|
|
_gnutls_send_server_certificate_request
|
6
|
17
|
40
|
gnutls_kx.c
|
|
_gnutls_mpi_dprint_lz
|
6
|
17
|
28
|
gnutls_mpi.c
|
|
gnutls_priority_get_cipher_suite_index
|
6
|
16
|
29
|
algorithms/ciphersuites.c
|
|
read_onepass_sig
|
6
|
16
|
22
|
opencdk/read-packet.c
|
|
gnutls_pkcs11_deinit
|
6
|
16
|
25
|
pkcs11.c
|
|
gnutls_dh_params_export_raw
|
6
|
16
|
34
|
gnutls_dh_primes.c
|
|
gnutls_openpgp_privkey_get_fingerprint
|
6
|
16
|
32
|
openpgp/privkey.c
|
|
gnutls_x509_crt_set_crq
|
6
|
16
|
34
|
x509/x509_write.c
|
|
gnutls_x509_crt_get_proxy
|
6
|
16
|
44
|
x509/x509.c
|
|
pkt_encode_len
|
6
|
16
|
31
|
opencdk/write-packet.c
|
|
cdk_stream_seek
|
6
|
16
|
32
|
opencdk/stream.c
|
|
_cdk_memistr
|
6
|
16
|
23
|
opencdk/misc.c
|
|
gnutls_openpgp_crt_get_subkey_fingerprint
|
6
|
15
|
30
|
openpgp/pgp.c
|
|
gnutls_openpgp_privkey_get_subkey_fingerprint
|
6
|
15
|
31
|
openpgp/privkey.c
|
|
_gnutls_check_algos
|
6
|
15
|
30
|
gnutls_constate.c
|
|
print_basic
|
6
|
15
|
30
|
x509/output.c
|
|
gnutls_openpgp_crt_get_fingerprint
|
6
|
15
|
29
|
openpgp/pgp.c
|
|
gnutls_ocsp_req_import
|
6
|
15
|
37
|
x509/ocsp.c
|
|
gnutls_ocsp_resp_get_response
|
6
|
15
|
37
|
x509/ocsp.c
|
|
_gnutls_ext_set_session_data
|
6
|
14
|
26
|
gnutls_extensions.c
|
|
_gnutls_recv_server_certificate_request
|
6
|
14
|
34
|
gnutls_kx.c
|
|
gnutls_db_remove_session
|
6
|
14
|
30
|
gnutls_db.c
|
|
_find_openpgp_cert
|
6
|
14
|
33
|
auth/cert.c
|
|
_gnutls_signature_algorithm_send_params
|
6
|
14
|
32
|
ext/signature.c
|
|
break_comma_list
|
6
|
14
|
30
|
gnutls_priority.c
|
|
text_decode
|
6
|
13
|
22
|
opencdk/literal.c
|
|
cdk_stream_peek
|
6
|
13
|
19
|
opencdk/stream.c
|
|
_gnutls_handshake_hash_add_recvd
|
6
|
13
|
31
|
gnutls_handshake.c
|
|
write_mpi
|
6
|
13
|
19
|
opencdk/write-packet.c
|
|
cdk_keydb_get_bypattern
|
6
|
12
|
23
|
opencdk/keydb.c
|
|
_gnutls_get_pgp_key_usage
|
6
|
12
|
18
|
openpgp/pgp.c
|
|
cdk_pk_fingerprint_get_keyid
|
6
|
12
|
23
|
opencdk/pubkey.c
|
|
send_handshake
|
6
|
12
|
26
|
gnutls_kx.c
|
|
_gnutls_init_record_state
|
6
|
12
|
26
|
gnutls_constate.c
|
|
find_issuer
|
6
|
12
|
33
|
x509/verify.c
|
|
_gnutls_certificate_get_rsa_params
|
6
|
12
|
29
|
gnutls_cert.c
|
|
_gnutls_get_dh_params
|
6
|
12
|
28
|
gnutls_dh.c
|
|
cdk_key_desig_revoker_walk
|
6
|
11
|
26
|
opencdk/new-packet.c
|
|
gnutls_fingerprint
|
6
|
11
|
24
|
gnutls_ui.c
|
|
oid2bag
|
6
|
11
|
16
|
x509/pkcs12.c
|
|
read_compressed
|
6
|
11
|
23
|
opencdk/read-packet.c
|
|
read_mdc
|
6
|
11
|
18
|
opencdk/read-packet.c
|
|
_cdk_stream_gets
|
6
|
11
|
21
|
opencdk/stream.c
|
|
record_check_version
|
6
|
10
|
34
|
gnutls_record.c
|
|
gnutls_x509_crt_set_proxy_dn
|
6
|
10
|
29
|
x509/x509_write.c
|
|
_gnutls_comp_init
|
5
|
27
|
55
|
gnutls_compress.c
|
|
gnutls_dh_get_peers_public_bits
|
5
|
22
|
47
|
gnutls_ui.c
|
|
gnutls_dh_get_prime_bits
|
5
|
22
|
45
|
gnutls_ui.c
|
|
gnutls_dh_get_pubkey
|
5
|
22
|
43
|
gnutls_ui.c
|
|
_gnutls_dh_set_secret_bits
|
5
|
21
|
41
|
gnutls_state.c
|
|
gnutls_dh_get_secret_bits
|
5
|
17
|
38
|
gnutls_ui.c
|
|
_gnutls_x509_read_pubkey
|
5
|
16
|
25
|
x509/key_decode.c
|
|
gnutls_privkey_deinit
|
5
|
11
|
26
|
gnutls_privkey.c
|
|
gnutls_certificate_activation_time_peers
|
5
|
11
|
35
|
gnutls_cert.c
|
|
gnutls_certificate_expiration_time_peers
|
5
|
11
|
35
|
gnutls_cert.c
|
|
gnutls_certificate_verify_peers2
|
5
|
10
|
29
|
gnutls_cert.c
|
|
update_crc
|
5
|
9
|
13
|
opencdk/armor.c
|
|
cdk_kbnode_walk
|
5
|
9
|
21
|
opencdk/kbnode.c
|
|
cdk_keydb_search_release
|
5
|
8
|
15
|
opencdk/keydb.c
|
|
_gnutls_ext_func_recv
|
5
|
8
|
12
|
gnutls_extensions.c
|
|
aes_cipher_init
|
5
|
8
|
20
|
accelerated/x86/aes-x86.c
|
|
aes_cipher_init
|
5
|
8
|
19
|
accelerated/x86/aes-padlock.c
|
|
gnutls_pk_list
|
5
|
8
|
15
|
algorithms/publickey.c
|
|
gnutls_x509_crt_set_subject_alternative_name
|
5
|
7
|
23
|
x509/x509_write.c
|
|
cdk_kbnode_find_prev
|
5
|
7
|
13
|
opencdk/kbnode.c
|
|
gnutls_global_set_mutex
|
5
|
6
|
12
|
locks.c
|
|
gnutls_db_check_entry
|
5
|
6
|
18
|
gnutls_db.c
|
|
gnutls_deinit
|
5
|
40
|
61
|
gnutls_state.c
|
|
_gnutls_pkcs11_privkey_decrypt_data
|
5
|
35
|
65
|
pkcs11_privkey.c
|
|
_gnutls_parse_supplemental
|
5
|
32
|
58
|
gnutls_supplemental.c
|
|
unpack_psk_auth_info
|
5
|
30
|
55
|
gnutls_session_pack.c
|
|
_gnutls_mac_deinit_ssl3_handshake
|
5
|
30
|
51
|
gnutls_hash_int.c
|
|
proc_ecdhe_psk_client_kx
|
5
|
30
|
64
|
auth/dhe_psk.c
|
|
_dtls_is_async
|
5
|
3
|
8
|
gnutls_dtls.h
|
|
_gnutls_kx_is_ecc
|
5
|
3
|
8
|
algorithms.h
|
|
pkcs11_find_object
|
5
|
29
|
48
|
pkcs11.c
|
|
_gnutls_ext_unpack
|
5
|
28
|
49
|
gnutls_extensions.c
|
|
_gnutls_proc_psk_server_kx
|
5
|
28
|
59
|
auth/psk.c
|
|
_gnutls_x509_crt_get_raw_dn2
|
5
|
28
|
58
|
x509/x509.c
|
|
_gnutls_x509_get_signature
|
5
|
28
|
57
|
x509/common.c
|
|
gnutls_x509_crq_set_key_rsa_raw
|
5
|
27
|
55
|
x509/crq.c
|
|
_wrap_nettle_pk_decrypt
|
5
|
27
|
63
|
nettle/pk.c
|
|
gnutls_pkcs11_token_get_mechanism
|
5
|
27
|
49
|
pkcs11.c
|
|
print_keyid
|
5
|
26
|
39
|
x509/output.c
|
|
gnutls_openpgp_privkey_sign_hash
|
5
|
26
|
56
|
openpgp/privkey.c
|
|
add_new_crt_to_rdn_seq
|
5
|
26
|
56
|
gnutls_x509.c
|
|
print_key_fingerprint
|
5
|
25
|
38
|
openpgp/output.c
|
|
_gnutls_x509_crt_cpy
|
5
|
25
|
44
|
x509/x509.c
|
|
create_empty_pfx
|
5
|
25
|
56
|
x509/pkcs12.c
|
|
_gnutls_x509_crl_cpy
|
5
|
25
|
45
|
x509/crl.c
|
|
_gnutls_ext_pack
|
5
|
25
|
44
|
gnutls_extensions.c
|
|
_gnutls_openpgp_privkey_cpy
|
5
|
24
|
38
|
openpgp/privkey.c
|
|
gnutls_pkcs11_token_init
|
5
|
24
|
45
|
pkcs11_write.c
|
|
_gnutls_handshake_io_write_flush
|
5
|
24
|
51
|
gnutls_buffers.c
|
|
gen_anon_server_kx
|
5
|
24
|
47
|
auth/anon.c
|
|
_gnutls_hash_init
|
5
|
24
|
43
|
gnutls_hash_int.c
|
|
unpack_anon_auth_info
|
5
|
24
|
48
|
gnutls_session_pack.c
|
|
_gnutls_hex2bin
|
5
|
24
|
41
|
gnutls_str.c
|
|
_gnutls_srp_gx
|
5
|
24
|
47
|
gnutls_srp.c
|
|
rsa_blind
|
5
|
24
|
53
|
nettle/pk.c
|
|
gnutls_ocsp_resp_get_nonce
|
5
|
24
|
47
|
x509/ocsp.c
|
|
_gnutls_x509_get_pk_algorithm
|
5
|
24
|
46
|
x509/common.c
|
|
gnutls_x509_crt_set_crl_dist_points2
|
5
|
23
|
57
|
x509/x509_write.c
|
|
pack_psk_auth_info
|
5
|
23
|
38
|
gnutls_session_pack.c
|
|
_gnutls_x509_raw_privkey_to_privkey
|
5
|
23
|
44
|
gnutls_x509.c
|
|
add_attribute
|
5
|
23
|
47
|
x509/crq.c
|
|
_gnutls_decode_ber_rs
|
5
|
23
|
45
|
gnutls_pk.c
|
|
_gnutls_x509_read_int
|
5
|
23
|
41
|
gnutls_mpi.c
|
|
_cdk_tmpfile
|
5
|
23
|
33
|
opencdk/misc.c
|
|
gnutls_x509_privkey_sign_data
|
5
|
23
|
50
|
x509/privkey.c
|
|
parse_der_ca_mem
|
5
|
23
|
44
|
gnutls_x509.c
|
|
gnutls_ocsp_req_set_nonce
|
5
|
22
|
41
|
x509/ocsp.c
|
|
gnutls_srp_verifier
|
5
|
22
|
43
|
gnutls_srp.c
|
|
_gnutls_handshake_select_v2_suite
|
5
|
22
|
41
|
gnutls_v2_compat.c
|
|
_gnutls_decompress
|
5
|
22
|
53
|
gnutls_compress.c
|
|
overwrite_extension
|
5
|
22
|
40
|
x509/extensions.c
|
|
_gnutls_ecc_ansi_x963_export
|
5
|
22
|
39
|
gnutls_ecc.c
|
|
_gnutls_x509_write_dsa_pubkey
|
5
|
22
|
45
|
x509/key_encode.c
|
|
gnutls_x509_crt_get_fingerprint
|
5
|
22
|
42
|
x509/x509.c
|
|
_gnutls_sign_algorithm_parse_data
|
5
|
22
|
41
|
ext/signature.c
|
|
gnutls_pubkey_import_ecc_raw
|
5
|
22
|
43
|
gnutls_pubkey.c
|
|
_gnutls_ssl3_generate_random
|
5
|
21
|
43
|
gnutls_hash_int.c
|
|
initialize_automatic_p11_kit
|
5
|
21
|
34
|
pkcs11.c
|
|
_gnutls_x509_read_rsa_pubkey
|
5
|
21
|
45
|
x509/key_decode.c
|
|
register_mac
|
5
|
21
|
37
|
accelerated/cryptodev.c
|
|
_gnutls_encode_ber_rs
|
5
|
21
|
43
|
gnutls_pk.c
|
|
register_crypto
|
5
|
21
|
40
|
accelerated/cryptodev.c
|
|
_gnutls_client_set_comp_method
|
5
|
21
|
39
|
gnutls_handshake.c
|
|
gnutls_x509_privkey_export_ecc_raw
|
5
|
21
|
46
|
x509/privkey.c
|
|
_gnutls_trustlist_inlist
|
5
|
20
|
35
|
x509/verify-high.c
|
|
_gnutls_x509_data2hex
|
5
|
20
|
38
|
x509/common.c
|
|
_gnutls_compress
|
5
|
20
|
51
|
gnutls_compress.c
|
|
gnutls_x509_privkey_generate
|
5
|
20
|
41
|
x509/privkey.c
|
|
gnutls_x509_crq_sign2
|
5
|
20
|
41
|
x509/crq.c
|
|
gnutls_pkcs12_bag_decrypt
|
5
|
19
|
44
|
x509/pkcs12_bag.c
|
|
gnutls_x509_crl_get_crt_serial
|
5
|
19
|
40
|
x509/crl.c
|
|
gnutls_pubkey_export
|
5
|
19
|
49
|
gnutls_pubkey.c
|
|
gnutls_session_get_data
|
5
|
19
|
37
|
gnutls_session.c
|
|
_cdk_copy_prefs
|
5
|
19
|
23
|
opencdk/new-packet.c
|
|
gnutls_x509_crt_list_import2
|
5
|
19
|
39
|
x509/x509.c
|
|
gnutls_x509_crt_list_import_pkcs11
|
5
|
19
|
36
|
pkcs11.c
|
|
gnutls_pkcs11_obj_list_import_url
|
5
|
19
|
43
|
pkcs11.c
|
|
_gnutls_get_key_id
|
5
|
19
|
36
|
x509/x509.c
|
|
gnutls_x509_crl_list_import2
|
5
|
19
|
39
|
x509/crl.c
|
|
_gnutls_str_array_append
|
5
|
18
|
33
|
gnutls_str_array.h
|
|
gnutls_pubkey_get_pk_ecc_raw
|
5
|
18
|
39
|
gnutls_pubkey.c
|
|
gnutls_privkey_import_x509
|
5
|
18
|
35
|
gnutls_privkey.c
|
|
_mbuffer_head_remove_bytes
|
5
|
18
|
33
|
gnutls_mbuffers.c
|
|
_gnutls_server_register_current_session
|
5
|
18
|
35
|
gnutls_db.c
|
|
alloc_and_load_pgp_certs
|
5
|
18
|
33
|
auth/cert.c
|
|
gnutls_x509_crq_get_basic_constraints
|
5
|
18
|
38
|
x509/crq.c
|
|
gnutls_x509_rdn_get
|
5
|
18
|
40
|
x509/dn.c
|
|
gnutls_pubkey_get_pk_rsa_raw
|
5
|
17
|
35
|
gnutls_pubkey.c
|
|
cdk_stream_get_length
|
5
|
17
|
33
|
opencdk/stream.c
|
|
hash_mpibuf
|
5
|
17
|
30
|
opencdk/sig-check.c
|
|
gnutls_rsa_export_get_pubkey
|
5
|
17
|
36
|
gnutls_ui.c
|
|
gnutls_x509_crq_get_extension_by_oid
|
5
|
17
|
37
|
x509/crq.c
|
|
_gnutls_gen_ecdh_common_client_kx_int
|
5
|
17
|
33
|
auth/ecdh_common.c
|
|
_gnutls_find_psk_key
|
5
|
17
|
31
|
auth/psk.c
|
|
gnutls_x509_crt_cpy_crl_dist_points
|
5
|
17
|
39
|
x509/x509_write.c
|
|
server_find_pk_algos_in_ciphersuites
|
5
|
16
|
31
|
gnutls_handshake.c
|
|
print_unique_ids
|
5
|
16
|
30
|
x509/output.c
|
|
_gnutls_writev
|
5
|
16
|
30
|
gnutls_buffers.c
|
|
gnutls_x509_crl_set_crt
|
5
|
16
|
33
|
x509/crl_write.c
|
|
calc_rsa_exp
|
5
|
16
|
33
|
nettle/pk.c
|
|
_gnutls_buffer_append_prefix
|
5
|
15
|
30
|
gnutls_str.c
|
|
_gnutls_send_server_certificate
|
5
|
15
|
36
|
gnutls_kx.c
|
|
gnutls_sign_algorithm_get_requested
|
5
|
15
|
35
|
ext/signature.c
|
|
_cdk_copy_userid
|
5
|
15
|
23
|
opencdk/new-packet.c
|
|
cdk_kbnode_commit
|
5
|
15
|
24
|
opencdk/kbnode.c
|
|
_gnutls_send_client_kx_message
|
5
|
15
|
33
|
gnutls_kx.c
|
|
_gnutls_recv_hello
|
5
|
15
|
34
|
gnutls_handshake.c
|
|
alloc_and_load_pkcs11_key
|
5
|
15
|
29
|
auth/cert.c
|
|
alloc_and_load_pgp_key
|
5
|
15
|
29
|
auth/cert.c
|
|
alloc_and_load_x509_key
|
5
|
15
|
29
|
auth/cert.c
|
|
read_new_length
|
5
|
14
|
27
|
opencdk/read-packet.c
|
|
_gnutls_uint48pp
|
5
|
14
|
24
|
gnutls_num.c
|
|
_gnutls_uint64pp
|
5
|
14
|
24
|
gnutls_num.c
|
|
_gnutls_writev_emu
|
5
|
14
|
25
|
gnutls_buffers.c
|
|
_cdk_filter_literal
|
5
|
14
|
22
|
opencdk/literal.c
|
|
_gnutls_ecc_ansi_x963_import
|
5
|
13
|
32
|
gnutls_ecc.c
|
|
_get_public_subkey
|
5
|
13
|
24
|
openpgp/pgp.c
|
|
_cdk_filter_armor
|
5
|
13
|
22
|
opencdk/armor.c
|
|
_gnutls_audit_log
|
5
|
13
|
23
|
gnutls_errors.c
|
|
_gnutls_ext_unset_resumed_session_data
|
5
|
13
|
26
|
gnutls_extensions.c
|
|
_gnutls_ext_unset_session_data
|
5
|
13
|
25
|
gnutls_extensions.c
|
|
gnutls_pkcs11_init
|
5
|
13
|
26
|
pkcs11.c
|
|
check_time
|
5
|
13
|
24
|
x509/verify.c
|
|
gnutls_pk_bits_to_sec_param
|
5
|
13
|
27
|
algorithms/secparams.c
|
|
_mbuffer_dequeue
|
5
|
13
|
24
|
gnutls_mbuffers.c
|
|
gnutls_x509_privkey_export
|
5
|
12
|
25
|
x509/privkey.c
|
|
gnutls_x509_crt_list_verify
|
5
|
12
|
38
|
x509/verify.c
|
|
cdk_kbnode_remove
|
5
|
12
|
21
|
opencdk/kbnode.c
|
|
_gnutls_auth_cipher_tag
|
5
|
12
|
26
|
gnutls_cipher_int.c
|
|
text_encode
|
5
|
12
|
23
|
opencdk/literal.c
|
|
_gnutls_version_max
|
5
|
11
|
19
|
algorithms/protocols.c
|
|
gnutls_pubkey_get_pk_ecc_x962
|
5
|
11
|
21
|
gnutls_pubkey.c
|
|
_gnutls_version_lowest
|
5
|
11
|
19
|
algorithms/protocols.c
|
|
_gnutls_ext_set_resumed_session_data
|
5
|
11
|
22
|
gnutls_extensions.c
|
|
gnutls_srp_set_client_credentials
|
5
|
11
|
24
|
gnutls_srp.c
|
|
_gnutls_epoch_set_compression
|
5
|
11
|
23
|
gnutls_constate.c
|
|
cdk_keydb_free
|
5
|
11
|
23
|
opencdk/keydb.c
|
|
_gnutls_auth_cipher_decrypt2
|
5
|
11
|
27
|
gnutls_cipher_int.c
|
|
cdk_keydb_get_byfpr
|
5
|
10
|
20
|
opencdk/keydb.c
|
|
cdk_keydb_get_bykeyid
|
5
|
10
|
19
|
opencdk/keydb.c
|
|
gnutls_pkcs11_obj_export
|
5
|
10
|
21
|
pkcs11.c
|
|
epoch_alive
|
5
|
10
|
20
|
gnutls_constate.c
|
|
_gnutls_io_check_recv
|
5
|
10
|
18
|
gnutls_buffers.c
|
|
search_header
|
5
|
10
|
17
|
opencdk/armor.c
|
|
_cdk_filter_text
|
5
|
10
|
18
|
opencdk/literal.c
|
|
gnutls_x509_crt_privkey_sign
|
5
|
10
|
28
|
x509/x509_write.c
|
|
check_schema
|
5
|
10
|
20
|
x509/privkey_pkcs8.c
|
|
cdk_pkt_write
|
5
|
31
|
54
|
opencdk/write-packet.c
|
|
gnutls_ocsp_resp_get_status
|
4
|
13
|
35
|
x509/ocsp.c
|
|
_cdk_pkt_get_fingerprint
|
4
|
6
|
21
|
opencdk/pubkey.c
|
|
gnutls_pkcs11_token_get_info
|
4
|
33
|
58
|
pkcs11.c
|
|
gnutls_privkey_decrypt_data
|
4
|
11
|
39
|
gnutls_privkey.c
|
|
gnutls_privkey_get_pk_algorithm
|
4
|
10
|
27
|
gnutls_privkey.c
|
|
gnutls_pubkey_import_pkcs11
|
4
|
18
|
43
|
gnutls_pubkey.c
|
|
_nettle_write_be32
|
4
|
17
|
36
|
accelerated/x86/sha-padlock.c
|
|
pkcs11_info_to_url
|
4
|
14
|
30
|
pkcs11.c
|
|
pubkey_verify_data
|
4
|
12
|
38
|
gnutls_pubkey.c
|
|
pubkey_verify_hashed_data
|
4
|
12
|
37
|
gnutls_pubkey.c
|
|
_gnutls_privkey_get_public_mpis
|
4
|
21
|
56
|
gnutls_privkey.c
|
|
wrap_nettle_cipher_setiv
|
4
|
11
|
29
|
nettle/cipher.c
|
|
_cdk_stream_get_opaque
|
4
|
9
|
15
|
opencdk/stream.c
|
|
cdk_subpkt_find_next
|
4
|
9
|
15
|
opencdk/new-packet.c
|
|
_gnutls_buffer_append_data_prefix
|
4
|
9
|
20
|
gnutls_str.c
|
|
cdk_subpkt_find_nth
|
4
|
9
|
15
|
opencdk/new-packet.c
|
|
prio_add
|
4
|
9
|
19
|
gnutls_priority.c
|
|
gnutls_certificate_get_ours
|
4
|
9
|
20
|
gnutls_ui.c
|
|
uid_list_all_signed
|
4
|
9
|
19
|
opencdk/sig-check.c
|
|
find_flags
|
4
|
9
|
27
|
pkcs11.c
|
|
_gnutls_x509_oid2pk_algorithm
|
4
|
9
|
15
|
algorithms/publickey.c
|
|
gnutls_x509_dn_oid_name
|
4
|
9
|
16
|
x509/common.c
|
|
gnutls_pk_get_id
|
4
|
9
|
15
|
algorithms/publickey.c
|
|
gnutls_ocsp_resp_get_signature
|
4
|
9
|
21
|
x509/ocsp.c
|
|
_gnutls_x509_oid2sign_algorithm
|
4
|
9
|
19
|
algorithms/sign.c
|
|
_gnutls_extension_list_check
|
4
|
9
|
18
|
gnutls_extensions.c
|
|
find_egd_name
|
4
|
9
|
21
|
nettle/egd.c
|
|
kbnode_find_valid
|
4
|
9
|
15
|
opencdk/keydb.c
|
|
_gnutls_ext_get_resumed_session_data
|
4
|
8
|
18
|
gnutls_extensions.c
|
|
_gnutls_ext_get_session_data
|
4
|
8
|
17
|
gnutls_extensions.c
|
|
gnutls_credentials_clear
|
4
|
8
|
16
|
gnutls_auth.c
|
|
_gnutls_comp_deinit
|
4
|
8
|
24
|
gnutls_compress.c
|
|
_gnutls_session_supports_ecc_curve
|
4
|
8
|
16
|
ext/ecc.c
|
|
_gnutls_tls_aid_to_sign
|
4
|
8
|
18
|
algorithms/sign.c
|
|
find_key_packet
|
4
|
8
|
14
|
opencdk/keydb.c
|
|
_gnutls_x509_oid2mac_algorithm
|
4
|
8
|
14
|
algorithms/mac.c
|
|
_gnutls_x509_pk_to_sign
|
4
|
8
|
14
|
algorithms/sign.c
|
|
write_head_new
|
4
|
8
|
14
|
opencdk/write-packet.c
|
|
cdk_pk_get_npkey
|
4
|
8
|
15
|
opencdk/pubkey.c
|
|
gnutls_mac_list
|
4
|
8
|
18
|
algorithms/mac.c
|
|
gnutls_dh_params_cpy
|
4
|
8
|
15
|
gnutls_dh_primes.c
|
|
_get_algo
|
4
|
7
|
19
|
crypto-backend.c
|
|
aes_gcm_cipher_init
|
4
|
7
|
17
|
accelerated/x86/aes-gcm-x86.c
|
|
aes_gcm_cipher_init
|
4
|
7
|
17
|
accelerated/x86/aes-gcm-padlock.c
|
|
_gnutls_map_kx_get_cred
|
4
|
7
|
17
|
algorithms/kx.c
|
|
copy_record_version
|
4
|
7
|
20
|
gnutls_record.c
|
|
retrieve_session
|
4
|
7
|
17
|
gnutls_db.c
|
|
_gnutls_supported_ecc_pf_send_params
|
4
|
7
|
15
|
ext/ecc.c
|
|
_gnutls_version_is_supported
|
4
|
7
|
16
|
algorithms/protocols.c
|
|
_gnutls_auth_cipher_add_auth
|
4
|
7
|
15
|
gnutls_cipher_int.c
|
|
gnutls_openpgp_crt_get_preferred_key_id
|
4
|
7
|
17
|
openpgp/pgp.c
|
|
gnutls_openpgp_privkey_get_preferred_key_id
|
4
|
7
|
17
|
openpgp/privkey.c
|
|
mech_to_pk
|
4
|
7
|
10
|
pkcs11_int.h
|
|
_dtls_async_timer_check
|
4
|
6
|
16
|
gnutls_dtls.h
|
|
cipher_suite_get
|
4
|
6
|
18
|
algorithms/ciphersuites.c
|
|
cdk_subpkt_get_data
|
4
|
6
|
10
|
opencdk/new-packet.c
|
|
cdk_sig_get_keyid
|
4
|
6
|
12
|
opencdk/pubkey.c
|
|
gnutls_certificate_type_get_id
|
4
|
6
|
12
|
algorithms/cert_types.c
|
|
_cdk_stream_get_fname
|
4
|
6
|
9
|
opencdk/stream.c
|
|
read_secret_subkey
|
4
|
6
|
12
|
opencdk/read-packet.c
|
|
_gnutls_auth_cipher_deinit
|
4
|
6
|
12
|
gnutls_cipher_int.c
|
|
cdk_sk_get_mpi
|
4
|
5
|
12
|
opencdk/pubkey.c
|
|
cdk_pk_get_mpi
|
4
|
5
|
12
|
opencdk/pubkey.c
|
|
check_via
|
4
|
5
|
14
|
accelerated/x86/aes-padlock.c
|
|
gnutls_ocsp_req_set_extension
|
4
|
4
|
15
|
x509/ocsp.c
|
|
_gnutls_pkcs11_privkey_sign_hash
|
4
|
33
|
59
|
pkcs11_privkey.c
|
|
cmp_hsk_types
|
4
|
3
|
8
|
gnutls_buffers.c
|
|
is_type_printable
|
4
|
3
|
9
|
x509/x509.c
|
|
gnutls_x509_crq_set_dn_by_oid
|
4
|
3
|
14
|
x509/crq.c
|
|
gnutls_x509_crt_set_dn_by_oid
|
4
|
3
|
13
|
x509/x509_write.c
|
|
_gnutls_dh_params_to_mpi
|
4
|
3
|
11
|
gnutls_dh_primes.c
|
|
_gnutls_abort_handshake
|
4
|
3
|
11
|
gnutls_handshake.c
|
|
db_func_is_ok
|
4
|
3
|
10
|
gnutls_db.c
|
|
gnutls_x509_crt_set_issuer_dn_by_oid
|
4
|
3
|
15
|
x509/x509_write.c
|
|
calc_ecdh_key
|
4
|
28
|
49
|
auth/ecdh_common.c
|
|
unpack_security_parameters
|
4
|
27
|
67
|
gnutls_session_pack.c
|
|
_gnutls_sign_algorithm_write_params
|
4
|
23
|
40
|
ext/signature.c
|
|
padlock_sha512_digest
|
4
|
23
|
43
|
accelerated/x86/sha-padlock.c
|
|
_gnutls_proc_ecdh_common_server_kx
|
4
|
23
|
36
|
auth/ecdh_common.c
|
|
_gnutls_x509_ext_extract_keyUsage
|
4
|
22
|
42
|
x509/extensions.c
|
|
wrap_nettle_generate_group
|
4
|
22
|
37
|
nettle/mpi.c
|
|
_gnutls_server_name_unpack
|
4
|
22
|
39
|
ext/server_name.c
|
|
_gnutls_mac_output_ssl3
|
4
|
22
|
37
|
gnutls_hash_int.c
|
|
_gnutls_handshake_sign_cert_vrfy12
|
4
|
21
|
43
|
gnutls_sig.c
|
|
_gnutls_cert_get_issuer_dn
|
4
|
21
|
42
|
auth/cert.c
|
|
generate_normal_master
|
4
|
20
|
65
|
gnutls_kx.c
|
|
_gnutls_x509_ext_gen_keyUsage
|
4
|
20
|
37
|
x509/extensions.c
|
|
_gnutls_set_psk_session_key
|
4
|
20
|
44
|
auth/psk.c
|
|
_gnutls_handshake_verify_cert_vrfy12
|
4
|
20
|
39
|
gnutls_sig.c
|
|
print_crq_other
|
4
|
20
|
36
|
x509/output.c
|
|
gnutls_x509_trust_list_add_named_crt
|
4
|
20
|
42
|
x509/verify-high.c
|
|
print_ski
|
4
|
20
|
36
|
x509/output.c
|
|
parse_der_crl_mem
|
4
|
20
|
39
|
gnutls_x509.c
|
|
gnutls_x509_trust_list_add_cas
|
4
|
20
|
37
|
x509/verify-high.c
|
|
_gnutls_x509_decode_and_read_attribute
|
4
|
19
|
44
|
x509/dn.c
|
|
gnutls_privkey_sign_hash
|
4
|
19
|
39
|
gnutls_privkey.c
|
|
gnutls_certificate_free_keys
|
4
|
19
|
28
|
gnutls_cert.c
|
|
proc_dhe_client_kx
|
4
|
19
|
38
|
auth/dhe.c
|
|
_gnutls_base64_decode
|
4
|
19
|
28
|
x509_b64.c
|
|
_gnutls_send_supplemental
|
4
|
19
|
39
|
gnutls_handshake.c
|
|
gnutls_x509_crt_print
|
4
|
19
|
42
|
x509/output.c
|
|
_gnutls_x509_privkey_sign_hash2
|
4
|
19
|
41
|
x509/privkey.c
|
|
parse_pem_ca_mem
|
4
|
19
|
37
|
gnutls_x509.c
|
|
_gnutls_x509_ext_gen_auth_key_id
|
4
|
19
|
39
|
x509/extensions.c
|
|
_gnutls_x509_ext_extract_number
|
4
|
18
|
42
|
x509/extensions.c
|
|
_gnutls_x509_set_time
|
4
|
18
|
34
|
x509/common.c
|
|
gnutls_privkey_sign_data
|
4
|
18
|
39
|
gnutls_privkey.c
|
|
read_key_mem
|
4
|
18
|
38
|
gnutls_x509.c
|
|
unpack_srp_auth_info
|
4
|
18
|
38
|
gnutls_session_pack.c
|
|
gnutls_x509_trust_list_get_issuer
|
4
|
18
|
32
|
x509/verify-high.c
|
|
cdk_keydb_new_from_mem
|
4
|
18
|
29
|
opencdk/keydb.c
|
|
_gnutls_server_restore_session
|
4
|
18
|
37
|
gnutls_db.c
|
|
_gnutls_calc_srp_S1
|
4
|
18
|
31
|
gnutls_srp.c
|
|
_gnutls_x509_get_signed_data
|
4
|
18
|
40
|
x509/common.c
|
|
gnutls_pubkey_import_ecc_x962
|
4
|
18
|
39
|
gnutls_pubkey.c
|
|
gnutls_pubkey_import_rsa_raw
|
4
|
18
|
36
|
gnutls_pubkey.c
|
|
_gnutls_x509_ext_gen_number
|
4
|
17
|
36
|
x509/extensions.c
|
|
wrap_padlock_hash_fast
|
4
|
17
|
44
|
accelerated/x86/sha-padlock.c
|
|
_mbuffer_linearize
|
4
|
17
|
30
|
gnutls_mbuffers.c
|
|
_gnutls_mac_init_ssl3
|
4
|
17
|
32
|
gnutls_hash_int.c
|
|
send_change_cipher_spec
|
4
|
17
|
32
|
gnutls_handshake.c
|
|
gnutls_x509_crt_import_pkcs11_url
|
4
|
17
|
35
|
pkcs11.c
|
|
_wrap_nettle_pk_encrypt
|
4
|
17
|
46
|
nettle/pk.c
|
|
gnutls_pcert_import_x509_raw
|
4
|
17
|
34
|
gnutls_pcert.c
|
|
gnutls_x509_crq_get_key_usage
|
4
|
17
|
36
|
x509/crq.c
|
|
gnutls_ocsp_resp_init
|
4
|
17
|
32
|
x509/ocsp.c
|
|
_gnutls_x509_ext_gen_key_id
|
4
|
17
|
36
|
x509/extensions.c
|
|
gnutls_pubkey_import_pkcs11_url
|
4
|
17
|
35
|
gnutls_pubkey.c
|
|
_gnutls_proc_ecdh_common_client_kx
|
4
|
16
|
29
|
auth/ecdh_common.c
|
|
gnutls_x509_crt_set_proxy
|
4
|
16
|
42
|
x509/x509_write.c
|
|
gnutls_x509_crt_set_key_usage
|
4
|
16
|
35
|
x509/x509_write.c
|
|
wrap_nettle_rnd
|
4
|
16
|
30
|
nettle/rnd.c
|
|
gnutls_x509_crt_set_basic_constraints
|
4
|
16
|
37
|
x509/x509_write.c
|
|
wrap_nettle_rnd_init
|
4
|
16
|
32
|
nettle/rnd.c
|
|
_gnutls_x509_read_der_int
|
4
|
16
|
38
|
x509/mpi.c
|
|
proc_psk_server_kx
|
4
|
16
|
34
|
auth/dhe_psk.c
|
|
gnutls_pkcs11_token_get_flags
|
4
|
16
|
30
|
pkcs11.c
|
|
gnutls_pkcs11_add_provider
|
4
|
16
|
30
|
pkcs11.c
|
|
gnutls_x509_crq_get_key_id
|
4
|
16
|
34
|
x509/crq.c
|
|
gnutls_x509_crt_get_key_id
|
4
|
16
|
34
|
x509/x509.c
|
|
gnutls_certificate_set_x509_trust_file
|
4
|
16
|
37
|
gnutls_x509.c
|
|
_gnutls_openpgp_fingerprint
|
4
|
16
|
31
|
openpgp/compat.c
|
|
gnutls_x509_crq_get_attribute_info
|
4
|
16
|
32
|
x509/crq.c
|
|
gnutls_x509_crl_get_extension_data
|
4
|
15
|
30
|
x509/crl.c
|
|
_gnutls_buffer_pop_datum_prefix
|
4
|
15
|
32
|
gnutls_str.c
|
|
get_issuers
|
4
|
15
|
38
|
auth/cert.c
|
|
export
|
4
|
15
|
25
|
x509/ocsp.c
|
|
_gnutls_rsa_verify
|
4
|
15
|
37
|
gnutls_pk.c
|
|
_gnutls_buffer_to_datum
|
4
|
15
|
31
|
gnutls_str.c
|
|
gnutls_x509_crq_set_key_usage
|
4
|
15
|
33
|
x509/crq.c
|
|
gnutls_x509_crq_set_basic_constraints
|
4
|
15
|
35
|
x509/crq.c
|
|
gnutls_x509_crt_get_extension_data
|
4
|
15
|
30
|
x509/x509.c
|
|
_gnutls_copy_comp_methods
|
4
|
15
|
27
|
gnutls_handshake.c
|
|
cdk_stream_set_hash_flag
|
4
|
15
|
26
|
opencdk/stream.c
|
|
gnutls_x509_crq_get_attribute_data
|
4
|
15
|
30
|
x509/crq.c
|
|
gnutls_x509_rdn_get_oid
|
4
|
15
|
35
|
x509/dn.c
|
|
gnutls_x509_rdn_get_by_oid
|
4
|
15
|
38
|
x509/dn.c
|
|
gnutls_prf
|
4
|
15
|
35
|
gnutls_state.c
|
|
gnutls_ocsp_req_randomize_nonce
|
4
|
15
|
29
|
x509/ocsp.c
|
|
gnutls_pkcs7_set_crl
|
4
|
14
|
28
|
x509/pkcs7.c
|
|
gnutls_pkcs7_get_crl_count
|
4
|
14
|
33
|
x509/pkcs7.c
|
|
gnutls_pkcs7_set_crt
|
4
|
14
|
28
|
x509/pkcs7.c
|
|
gnutls_openpgp_crt_check_hostname
|
4
|
14
|
29
|
openpgp/pgp.c
|
|
gnutls_certificate_set_openpgp_keyring_file
|
4
|
14
|
31
|
openpgp/gnutls_openpgp.c
|
|
gnutls_privkey_import_ext
|
4
|
14
|
29
|
gnutls_privkey.c
|
|
gnutls_pkcs7_get_crt_count
|
4
|
14
|
33
|
x509/pkcs7.c
|
|
checksum_mpi
|
4
|
14
|
17
|
opencdk/pubkey.c
|
|
gnutls_certificate_set_x509_crl_file
|
4
|
14
|
30
|
gnutls_x509.c
|
|
_gnutls_signature_algorithm_recv_params
|
4
|
14
|
41
|
ext/signature.c
|
|
_gnutls_client_check_if_resuming
|
4
|
14
|
48
|
gnutls_handshake.c
|
|
gnutls_x509_crq_set_challenge_password
|
4
|
13
|
33
|
x509/crq.c
|
|
gnutls_x509_trust_list_init
|
4
|
13
|
25
|
x509/verify-high.c
|
|
cdk_stream_filter_disable
|
4
|
13
|
23
|
opencdk/stream.c
|
|
_gnutls_recv_server_certificate
|
4
|
13
|
34
|
gnutls_kx.c
|
|
gnutls_openpgp_crt_get_subkey_count
|
4
|
13
|
24
|
openpgp/pgp.c
|
|
gen_anon_ecdh_server_kx
|
4
|
13
|
30
|
auth/anon_ecdh.c
|
|
gnutls_pem_base64_decode
|
4
|
13
|
28
|
x509_b64.c
|
|
gnutls_openpgp_privkey_get_subkey_count
|
4
|
13
|
24
|
openpgp/privkey.c
|
|
gnutls_srp_base64_decode
|
4
|
13
|
26
|
auth/srp_sb64.c
|
|
gnutls_ocsp_req_get_version
|
4
|
13
|
24
|
x509/ocsp.c
|
|
gnutls_srp_base64_encode
|
4
|
13
|
26
|
auth/srp_sb64.c
|
|
gnutls_pem_base64_encode
|
4
|
13
|
26
|
x509_b64.c
|
|
_gnutls_openpgp_count_key_names
|
4
|
13
|
24
|
openpgp/pgp.c
|
|
_gnutls_buffer_pop_datum
|
4
|
13
|
29
|
gnutls_str.c
|
|
get_server_name
|
4
|
13
|
19
|
auth/cert.c
|
|
_gnutls_hmac_fast
|
4
|
13
|
31
|
gnutls_hash_int.c
|
|
_gnutls_hash_fast
|
4
|
13
|
30
|
gnutls_hash_int.c
|
|
find_selfsig_node
|
4
|
13
|
21
|
opencdk/keydb.c
|
|
gnutls_ocsp_resp_get_produced
|
4
|
13
|
26
|
x509/ocsp.c
|
|
cdk_kbnode_insert
|
4
|
13
|
25
|
opencdk/kbnode.c
|
|
gnutls_ocsp_resp_get_version
|
4
|
13
|
24
|
x509/ocsp.c
|
|
gnutls_openpgp_crt_get_subkey_id
|
4
|
12
|
24
|
openpgp/pgp.c
|
|
read_old_length
|
4
|
12
|
26
|
opencdk/read-packet.c
|
|
gnutls_openpgp_crt_get_subkey_pk_algorithm
|
4
|
12
|
26
|
openpgp/pgp.c
|
|
gnutls_x509_crq_get_version
|
4
|
12
|
26
|
x509/crq.c
|
|
gnutls_x509_crq_set_version
|
4
|
12
|
25
|
x509/crq.c
|
|
gnutls_openpgp_privkey_get_subkey_id
|
4
|
12
|
24
|
openpgp/privkey.c
|
|
_gnutls_buffer_pop_prefix
|
4
|
12
|
26
|
gnutls_str.c
|
|
gnutls_x509_crt_get_version
|
4
|
12
|
26
|
x509/x509.c
|
|
gnutls_pkcs12_bag_set_key_id
|
4
|
12
|
30
|
x509/pkcs12_bag.c
|
|
gnutls_x509_crl_set_version
|
4
|
12
|
24
|
x509/crl_write.c
|
|
_int_rsa_verify
|
4
|
12
|
28
|
nettle/pk.c
|
|
_cdk_copy_signature
|
4
|
12
|
20
|
opencdk/new-packet.c
|
|
gnutls_openpgp_crt_get_key_id
|
4
|
12
|
23
|
openpgp/pgp.c
|
|
gnutls_openpgp_privkey_get_key_id
|
4
|
12
|
23
|
openpgp/privkey.c
|
|
gnutls_openpgp_crt_get_pk_algorithm
|
4
|
12
|
24
|
openpgp/pgp.c
|
|
_gnutls_recv_hello_request
|
4
|
12
|
25
|
gnutls_handshake.c
|
|
gnutls_openpgp_privkey_get_pk_algorithm
|
4
|
12
|
24
|
openpgp/privkey.c
|
|
gnutls_session_set_data
|
4
|
12
|
24
|
gnutls_session.c
|
|
gnutls_x509_crt_set_version
|
4
|
12
|
24
|
x509/x509_write.c
|
|
dsa_verify_hashed_data
|
4
|
12
|
27
|
gnutls_pubkey.c
|
|
cdk_stream_enable_cache
|
4
|
12
|
23
|
opencdk/stream.c
|
|
gnutls_x509_crq_set_pubkey
|
4
|
11
|
27
|
gnutls_pubkey.c
|
|
gnutls_calc_dh_key
|
4
|
11
|
19
|
gnutls_dh.c
|
|
gnutls_x509_crt_set_pubkey
|
4
|
11
|
27
|
gnutls_pubkey.c
|
|
gnutls_x509_crt_get_pk_algorithm
|
4
|
11
|
28
|
x509/x509.c
|
|
_cdk_filter_hash
|
4
|
11
|
20
|
opencdk/hash.c
|
|
_gnutls_epoch_get
|
4
|
11
|
20
|
gnutls_constate.c
|
|
_set_priority
|
4
|
11
|
18
|
gnutls_priority.c
|
|
gnutls_pkcs12_bag_set_friendly_name
|
4
|
11
|
26
|
x509/pkcs12_bag.c
|
|
gnutls_cipher_init
|
4
|
11
|
23
|
crypto-api.c
|
|
_gnutls_recv_client_kx_message
|
4
|
11
|
30
|
gnutls_kx.c
|
|
do_write
|
4
|
11
|
20
|
nettle/egd.c
|
|
prio_remove
|
4
|
11
|
22
|
gnutls_priority.c
|
|
gnutls_cipher_set_priority
|
4
|
11
|
18
|
gnutls_priority.c
|
|
gnutls_strerror
|
4
|
11
|
21
|
gnutls_errors.c
|
|
_gnutls_user_hello_func
|
4
|
11
|
26
|
gnutls_handshake.c
|
|
gnutls_error_is_fatal
|
4
|
11
|
22
|
gnutls_errors.c
|
|
write_mdc
|
4
|
11
|
19
|
opencdk/write-packet.c
|
|
gnutls_psk_set_server_credentials_file
|
4
|
11
|
27
|
gnutls_psk.c
|
|
cdk_pk_get_nskey
|
4
|
11
|
20
|
opencdk/pubkey.c
|
|
gen_ecdhe_psk_server_kx
|
4
|
11
|
24
|
auth/dhe_psk.c
|
|
_gnutls_get_selected_cert
|
4
|
11
|
38
|
auth/cert.c
|
|
_gnutls_soft_sign
|
4
|
11
|
30
|
gnutls_sig.c
|
|
gnutls_ocsp_resp_deinit
|
4
|
11
|
18
|
x509/ocsp.c
|
|
wrap_nettle_pk_fixup
|
4
|
11
|
32
|
nettle/pk.c
|
|
gnutls_openpgp_crt_get_subkey_revoked_status
|
4
|
10
|
20
|
openpgp/pgp.c
|
|
_gnutls_set_datum_m
|
4
|
10
|
20
|
gnutls_datum.c
|
|
check_bits
|
4
|
10
|
21
|
gnutls_x509.c
|
|
gnutls_openpgp_crt_get_revoked_status
|
4
|
10
|
19
|
openpgp/pgp.c
|
|
gnutls_x509_crl_privkey_sign
|
4
|
10
|
28
|
x509/crl_write.c
|
|
gnutls_openpgp_privkey_get_subkey_revoked_status
|
4
|
10
|
20
|
openpgp/privkey.c
|
|
_get_secret_subkey
|
4
|
10
|
18
|
openpgp/privkey.c
|
|
gnutls_ocsp_req_export
|
4
|
10
|
22
|
x509/ocsp.c
|
|
gnutls_openpgp_privkey_get_revoked_status
|
4
|
10
|
19
|
openpgp/privkey.c
|
|
gnutls_session_channel_binding
|
4
|
10
|
20
|
gnutls_state.c
|
|
gnutls_certificate_set_x509_key_file
|
4
|
10
|
26
|
gnutls_x509.c
|
|
gnutls_session_get_data2
|
4
|
10
|
23
|
gnutls_session.c
|
|
is_armored
|
4
|
8
|
25
|
opencdk/armor.c
|
|
_cdk_pkt_write2
|
3
|
17
|
33
|
opencdk/write-packet.c
|
|
_cdk_pkt_get_keyid
|
3
|
12
|
31
|
opencdk/pubkey.c
|
|
_cdk_pkt_detach_free
|
3
|
9
|
28
|
opencdk/new-packet.c
|
|
_gnutls_privkey_sign_hash
|
3
|
8
|
30
|
gnutls_privkey.c
|
|
_gnutls_x509_write_pubkey_params
|
3
|
9
|
23
|
x509/key_encode.c
|
|
padlock_aes_cipher_setkey
|
3
|
26
|
52
|
accelerated/x86/aes-padlock.c
|
|
encode
|
3
|
21
|
43
|
x509_b64.c
|
|
calc_s2ksize
|
3
|
12
|
23
|
opencdk/write-packet.c
|
|
pk_prepare_hash
|
3
|
11
|
30
|
gnutls_sig.c
|
|
epoch_resolve
|
3
|
10
|
26
|
gnutls_constate.c
|
|
gnutls_error_to_alert
|
3
|
55
|
113
|
gnutls_alert.c
|
|
_gnutls_gen_cert_client_certificate
|
3
|
6
|
21
|
auth/cert.c
|
|
_gnutls_get_auth_info_pcert
|
3
|
5
|
23
|
gnutls_pcert.c
|
|
st_to_st2
|
3
|
13
|
30
|
auth/cert.c
|
|
gnutls_openpgp_crt_get_subkey_expiration_time
|
3
|
9
|
18
|
openpgp/pgp.c
|
|
gnutls_x509_crt_set_serial
|
3
|
9
|
24
|
x509/x509_write.c
|
|
gnutls_openpgp_crt_get_subkey_creation_time
|
3
|
9
|
18
|
openpgp/pgp.c
|
|
gnutls_x509_crq_set_key
|
3
|
9
|
24
|
x509/crq.c
|
|
_gnutls_epoch_refcount_dec
|
3
|
9
|
15
|
gnutls_constate.h
|
|
_gnutls_buffer_pop_data_prefix
|
3
|
9
|
19
|
gnutls_str.c
|
|
cdk_subpkt_add
|
3
|
9
|
12
|
opencdk/new-packet.c
|
|
gnutls_openpgp_privkey_get_subkey_expiration_time
|
3
|
9
|
18
|
openpgp/privkey.c
|
|
write_compressed
|
3
|
9
|
17
|
opencdk/write-packet.c
|
|
gnutls_openpgp_crt_get_key_usage
|
3
|
9
|
20
|
openpgp/pgp.c
|
|
_gnutls_ext_free_session_data
|
3
|
9
|
16
|
gnutls_extensions.c
|
|
gnutls_openpgp_privkey_get_subkey_creation_time
|
3
|
9
|
18
|
openpgp/privkey.c
|
|
gnutls_pkcs12_bag_get_key_id
|
3
|
9
|
21
|
x509/pkcs12_bag.c
|
|
cdk_subpkt_type_count
|
3
|
9
|
15
|
opencdk/new-packet.c
|
|
gnutls_pubkey_get_key_id
|
3
|
9
|
24
|
gnutls_pubkey.c
|
|
gnutls_x509_crl_init
|
3
|
9
|
20
|
x509/crl.c
|
|
keydb_idx_mkname
|
3
|
9
|
14
|
opencdk/keydb.c
|
|
gnutls_openpgp_crt_get_expiration_time
|
3
|
9
|
17
|
openpgp/pgp.c
|
|
gnutls_x509_crl_get_crt_count
|
3
|
9
|
24
|
x509/crl.c
|
|
gnutls_strerror_name
|
3
|
9
|
17
|
gnutls_errors.c
|
|
gnutls_openpgp_crt_get_creation_time
|
3
|
9
|
17
|
openpgp/pgp.c
|
|
gnutls_openpgp_crt_get_version
|
3
|
9
|
17
|
openpgp/pgp.c
|
|
_pkcs12_check_pass
|
3
|
9
|
15
|
x509/pkcs12_encr.c
|
|
_gnutls_negotiate_version
|
3
|
9
|
30
|
gnutls_handshake.c
|
|
gnutls_x509_crt_verify_hash
|
3
|
9
|
22
|
x509/x509.c
|
|
gnutls_x509_crt_verify_data
|
3
|
9
|
22
|
x509/x509.c
|
|
_gnutls_x509_pk_to_oid
|
3
|
9
|
15
|
algorithms/publickey.c
|
|
gnutls_x509_crt_set_key
|
3
|
9
|
24
|
x509/x509_write.c
|
|
gnutls_pk_get_name
|
3
|
9
|
15
|
algorithms/publickey.c
|
|
gnutls_x509_privkey_sign_hash
|
3
|
9
|
23
|
x509/privkey.c
|
|
gnutls_pkcs7_init
|
3
|
9
|
20
|
x509/pkcs7.c
|
|
proc_anon_server_kx
|
3
|
9
|
25
|
auth/anon.c
|
|
gnutls_pkcs12_init
|
3
|
9
|
20
|
x509/pkcs12.c
|
|
write_mpibuf
|
3
|
9
|
14
|
opencdk/write-packet.c
|
|
drop_usage_count
|
3
|
9
|
15
|
gnutls_dtls.c
|
|
proc_anon_ecdh_server_kx
|
3
|
9
|
25
|
auth/anon_ecdh.c
|
|
_gnutls_x509_write_ecc_pubkey
|
3
|
9
|
18
|
x509/key_encode.c
|
|
gnutls_openpgp_crt_get_subkey_usage
|
3
|
9
|
21
|
openpgp/pgp.c
|
|
gnutls_x509_crl_get_extension_oid
|
3
|
8
|
21
|
x509/crl.c
|
|
aes_cipher_setkey
|
3
|
8
|
16
|
accelerated/x86/aes-x86.c
|
|
gnutls_pkcs12_bag_get_friendly_name
|
3
|
8
|
20
|
x509/pkcs12_bag.c
|
|
cdk_subpkt_new
|
3
|
8
|
14
|
opencdk/new-packet.c
|
|
filter_search
|
3
|
8
|
15
|
opencdk/stream.c
|
|
cdk_pkt_new
|
3
|
8
|
13
|
opencdk/new-packet.c
|
|
read_cert_mem
|
3
|
8
|
19
|
gnutls_x509.c
|
|
_cdk_sk_get_csum
|
3
|
8
|
11
|
opencdk/pubkey.c
|
|
ecc_new_point
|
3
|
8
|
16
|
nettle/ecc_points.c
|
|
gnutls_psk_client_get_hint
|
3
|
8
|
16
|
gnutls_psk.c
|
|
gnutls_psk_server_get_username
|
3
|
8
|
16
|
gnutls_psk.c
|
|
get_keyid
|
3
|
8
|
20
|
openpgp/gnutls_openpgp.c
|
|
_gnutls_openpgp_get_algo
|
3
|
8
|
17
|
openpgp/privkey.c
|
|
gnutls_cipher_list
|
3
|
8
|
18
|
algorithms/ciphers.c
|
|
gnutls_rsa_params_export_raw
|
3
|
8
|
21
|
gnutls_rsa_export.c
|
|
cache_sig_result
|
3
|
8
|
16
|
opencdk/sig-check.c
|
|
_mbuffer_head_get_next
|
3
|
8
|
20
|
gnutls_mbuffers.c
|
|
gnutls_x509_crt_get_extension_oid
|
3
|
8
|
21
|
x509/x509.c
|
|
_mbuffer_head_get_first
|
3
|
8
|
20
|
gnutls_mbuffers.c
|
|
gnutls_pkcs12_bag_get_data
|
3
|
8
|
18
|
x509/pkcs12_bag.c
|
|
gnutls_session_get_id
|
3
|
8
|
24
|
gnutls_session.c
|
|
_gnutls_mpi_scan_nz
|
3
|
8
|
19
|
gnutls_mpi.c
|
|
gnutls_x509_privkey_get_key_id
|
3
|
8
|
22
|
x509/privkey.c
|
|
gnutls_pubkey_verify_data2
|
3
|
8
|
24
|
gnutls_pubkey.c
|
|
gnutls_openpgp_crt_verify_self
|
3
|
8
|
17
|
openpgp/pgpverify.c
|
|
gnutls_pubkey_verify_data
|
3
|
8
|
22
|
gnutls_pubkey.c
|
|
_gnutls_handshake_hash_add_sent
|
3
|
8
|
24
|
gnutls_handshake.c
|
|
gnutls_x509_crq_get_pk_algorithm
|
3
|
8
|
20
|
x509/crq.c
|
|
_gnutls_send_empty_handshake
|
3
|
8
|
20
|
gnutls_handshake.c
|
|
find_crl_issuer
|
3
|
8
|
18
|
x509/verify.c
|
|
skip_packet
|
3
|
7
|
14
|
opencdk/read-packet.c
|
|
get_supp_func_recv
|
3
|
7
|
11
|
gnutls_supplemental.c
|
|
_gnutls_ext_func_unpack
|
3
|
7
|
11
|
gnutls_extensions.c
|
|
gnutls_alert_get_name
|
3
|
7
|
11
|
gnutls_alert.c
|
|
gnutls_supplemental_get_name
|
3
|
7
|
11
|
gnutls_supplemental.c
|
|
_gnutls_ext_func_deinit
|
3
|
7
|
11
|
gnutls_extensions.c
|
|
_gnutls_buffer_asciiprint
|
3
|
7
|
12
|
gnutls_str.c
|
|
_gnutls_buffer_hexprint
|
3
|
7
|
14
|
gnutls_str.c
|
|
cdk_kbnode_release
|
3
|
7
|
14
|
opencdk/kbnode.c
|
|
gnutls_realloc_fast
|
3
|
7
|
16
|
gnutls_mem.c
|
|
_gnutls_mac_priority
|
3
|
7
|
12
|
algorithms/mac.c
|
|
_gnutls_version_priority
|
3
|
7
|
12
|
algorithms/protocols.c
|
|
gnutls_random_art
|
3
|
7
|
16
|
gnutls_ui.c
|
|
_gnutls_ext_parse_type
|
3
|
7
|
13
|
gnutls_extensions.c
|
|
gnutls_secure_calloc
|
3
|
7
|
10
|
gnutls_mem.c
|
|
_gnutls_epoch_set_null_algos
|
3
|
7
|
18
|
gnutls_constate.c
|
|
_gnutls_calloc
|
3
|
7
|
10
|
gnutls_mem.c
|
|
_gnutls_str_cat
|
3
|
7
|
19
|
gnutls_str.c
|
|
dup_trim_filename
|
3
|
7
|
12
|
opencdk/literal.c
|
|
wrap_nettle_mpi_mulm
|
3
|
7
|
15
|
nettle/mpi.c
|
|
wrap_nettle_mpi_subm
|
3
|
7
|
15
|
nettle/mpi.c
|
|
wrap_nettle_mpi_addm
|
3
|
7
|
15
|
nettle/mpi.c
|
|
pkt_write_head2
|
3
|
7
|
12
|
opencdk/write-packet.c
|
|
_gnutls_x509_oid2asn_string
|
3
|
7
|
15
|
x509/common.c
|
|
read_crl_mem
|
3
|
7
|
18
|
gnutls_x509.c
|
|
_gnutls_x509_oid_data_choice
|
3
|
7
|
15
|
x509/common.c
|
|
_gnutls_check_pk_algo_in_list
|
3
|
7
|
15
|
auth/cert.c
|
|
gnutls_certificate_set_x509_trust_mem
|
3
|
7
|
19
|
gnutls_x509.c
|
|
gnutls_x509_dn_oid_known
|
3
|
7
|
15
|
x509/common.c
|
|
gcm_ghash
|
3
|
7
|
15
|
accelerated/x86/aes-gcm-x86.c
|
|
_gnutls_kx_priority
|
3
|
7
|
12
|
algorithms/kx.c
|
|
print_key_revoked
|
3
|
7
|
15
|
openpgp/output.c
|
|
_gnutls_x509_compare_raw_dn
|
3
|
7
|
17
|
x509/dn.c
|
|
_gnutls_cipher_priority
|
3
|
7
|
12
|
algorithms/ciphers.c
|
|
gnutls_alert_get_strname
|
3
|
7
|
11
|
gnutls_alert.c
|
|
_gnutls_x509_oid_data_printable
|
3
|
7
|
15
|
x509/common.c
|
|
_gnutls_extension_get_name
|
3
|
7
|
11
|
gnutls_extensions.c
|
|
gnutls_ocsp_req_deinit
|
3
|
6
|
13
|
x509/ocsp.c
|
|
_gnutls_set_kx
|
3
|
6
|
16
|
gnutls_constate.c
|
|
gnutls_openpgp_keyring_deinit
|
3
|
6
|
14
|
openpgp/extras.c
|
|
gnutls_openpgp_privkey_deinit
|
3
|
6
|
14
|
openpgp/privkey.c
|
|
gnutls_openpgp_crt_deinit
|
3
|
6
|
14
|
openpgp/pgp.c
|
|
_gnutls_str_array_match
|
3
|
6
|
12
|
gnutls_str_array.h
|
|
cdk_sk_get_keyid
|
3
|
6
|
14
|
opencdk/pubkey.c
|
|
_gnutls_str_cpy
|
3
|
6
|
18
|
gnutls_str.c
|
|
wrap_nettle_mpi_mul_ui
|
3
|
6
|
14
|
nettle/mpi.c
|
|
gnutls_certificate_type_get_name
|
3
|
6
|
12
|
algorithms/cert_types.c
|
|
wrap_nettle_mpi_sub_ui
|
3
|
6
|
14
|
nettle/mpi.c
|
|
wrap_nettle_mpi_add_ui
|
3
|
6
|
13
|
nettle/mpi.c
|
|
wrap_nettle_mpi_div
|
3
|
6
|
13
|
nettle/mpi.c
|
|
wrap_nettle_mpi_mul
|
3
|
6
|
13
|
nettle/mpi.c
|
|
wrap_nettle_mpi_sub
|
3
|
6
|
13
|
nettle/mpi.c
|
|
wrap_nettle_mpi_add
|
3
|
6
|
13
|
nettle/mpi.c
|
|
_gnutls_hmac_deinit
|
3
|
6
|
14
|
gnutls_hash_int.c
|
|
cdk_listkey_close
|
3
|
6
|
12
|
opencdk/keydb.c
|
|
deinit_internal_params
|
3
|
6
|
13
|
gnutls_state.c
|
|
wrap_nettle_mpi_powm
|
3
|
6
|
14
|
nettle/mpi.c
|
|
cdk_kbnode_find
|
3
|
6
|
10
|
opencdk/kbnode.c
|
|
pkcs11_obj_flags_to_int
|
3
|
6
|
12
|
pkcs11.c
|
|
gnutls_pubkey_verify_hash
|
3
|
6
|
19
|
gnutls_pubkey.c
|
|
_gnutls_buffer_clear
|
3
|
6
|
11
|
gnutls_str.c
|
|
_gnutls_hash_deinit
|
3
|
6
|
14
|
gnutls_hash_int.c
|
|
gnutls_pkcs12_bag_get_type
|
3
|
6
|
13
|
x509/pkcs12_bag.c
|
|
pk_to_mech
|
3
|
5
|
9
|
pkcs11_int.h
|
|
gnutls_x509_crq_deinit
|
3
|
5
|
11
|
x509/crq.c
|
|
gnutls_x509_crl_deinit
|
3
|
5
|
11
|
x509/crl.c
|
|
_gnutls_get_max_decrypted_data
|
3
|
5
|
12
|
gnutls_record.c
|
|
_gnutls_pk_get_hash_algorithm
|
3
|
5
|
18
|
gnutls_pk.c
|
|
_gnutls_rnd_init
|
3
|
5
|
14
|
random.c
|
|
_gnutls_sign_to_tls_aid
|
3
|
5
|
12
|
algorithms/sign.c
|
|
cdk_pk_get_nenc
|
3
|
5
|
10
|
opencdk/pubkey.c
|
|
_gnutls_extension_list_add
|
3
|
5
|
18
|
gnutls_extensions.c
|
|
cdk_pk_get_nsig
|
3
|
5
|
10
|
opencdk/pubkey.c
|
|
gnutls_pkcs7_deinit
|
3
|
5
|
11
|
x509/pkcs7.c
|
|
gnutls_pkcs12_deinit
|
3
|
5
|
11
|
x509/pkcs12.c
|
|
gnutls_x509_crt_deinit
|
3
|
5
|
11
|
x509/x509.c
|
|
pk_to_genmech
|
3
|
5
|
9
|
pkcs11_int.h
|
|
_gnutls_session_is_psk
|
3
|
5
|
13
|
gnutls_state.c
|
|
_gnutls_mem_cpy
|
3
|
4
|
17
|
gnutls_str.c
|
|
gnutls_ocsp_resp_export
|
3
|
4
|
11
|
x509/ocsp.c
|
|
_gnutls_version_get
|
3
|
4
|
9
|
algorithms/protocols.c
|
|
gnutls_pubkey_encrypt_data
|
3
|
4
|
15
|
gnutls_pubkey.c
|
|
pack_security_parameters
|
3
|
31
|
58
|
gnutls_session_pack.c
|
|
_gnutls_cipher_deinit
|
3
|
3
|
9
|
gnutls_cipher_int.h
|
|
_gnutls_cipher_decrypt2
|
3
|
3
|
12
|
gnutls_cipher_int.h
|
|
_gnutls_cipher_encrypt2
|
3
|
3
|
12
|
gnutls_cipher_int.h
|
|
gnutls_check_version
|
3
|
3
|
8
|
gnutls_global.c
|
|
read_public_subkey
|
3
|
3
|
7
|
opencdk/read-packet.c
|
|
_gnutls_pubkey_is_over_rsa_512
|
3
|
3
|
8
|
gnutls_pubkey.c
|
|
cdk_pk_get_nbits
|
3
|
3
|
7
|
opencdk/pubkey.c
|
|
_gnutls_cipher_auth
|
3
|
3
|
9
|
gnutls_cipher_int.h
|
|
guiddump
|
3
|
23
|
29
|
x509/output.c
|
|
pack_certificate_auth_info
|
3
|
21
|
38
|
gnutls_session_pack.c
|
|
ecc_map
|
3
|
20
|
37
|
nettle/ecc_map.c
|
|
cdk_stream_tmp_set_mode
|
3
|
2
|
6
|
opencdk/stream.c
|
|
_gnutls_cipher_tag
|
3
|
2
|
7
|
gnutls_cipher_int.h
|
|
_gnutls_calc_srp_sha
|
3
|
18
|
35
|
gnutls_srp.c
|
|
proc_anon_client_kx
|
3
|
18
|
35
|
auth/anon.c
|
|
_gnutls_x509_get_tbs
|
3
|
17
|
32
|
x509/sign.c
|
|
_gnutls_buffer_unescape
|
3
|
17
|
32
|
gnutls_str.c
|
|
signature_algorithms_unpack
|
3
|
17
|
30
|
ext/signature.c
|
|
read_pkcs12_kdf_params
|
3
|
17
|
38
|
x509/privkey_pkcs8.c
|
|
_gnutls_ssl3_hash_md5
|
3
|
16
|
33
|
gnutls_hash_int.c
|
|
ssl3_md5
|
3
|
16
|
30
|
gnutls_hash_int.c
|
|
ssl3_sha
|
3
|
16
|
28
|
gnutls_hash_int.c
|
|
cdk_stream_tmp_from_mem
|
3
|
16
|
26
|
opencdk/stream.c
|
|
gnutls_pkcs11_token_get_url
|
3
|
16
|
31
|
pkcs11.c
|
|
parse_pem_crl_mem
|
3
|
16
|
31
|
gnutls_x509.c
|
|
_gnutls_x509_write_attribute
|
3
|
15
|
35
|
x509/dn.c
|
|
filter_add
|
3
|
15
|
23
|
opencdk/stream.c
|
|
_gnutls_calc_srp_A
|
3
|
15
|
26
|
gnutls_srp.c
|
|
aes_gcm_decrypt
|
3
|
15
|
29
|
accelerated/x86/aes-gcm-x86.c
|
|
aes_gcm_encrypt
|
3
|
15
|
29
|
accelerated/x86/aes-gcm-x86.c
|
|
_cdk_free_signature
|
3
|
15
|
24
|
opencdk/new-packet.c
|
|
is_crl_issuer
|
3
|
14
|
30
|
x509/verify.c
|
|
_decode_pkcs8_ecc_key
|
3
|
14
|
27
|
x509/privkey_pkcs8.c
|
|
gnutls_dh_params_import_raw
|
3
|
14
|
31
|
gnutls_dh_primes.c
|
|
gnutls_ocsp_resp_print
|
3
|
14
|
31
|
x509/ocsp_output.c
|
|
_parse_safe_contents
|
3
|
14
|
32
|
x509/pkcs12.c
|
|
_gnutls_is_same_dn
|
3
|
14
|
29
|
x509/verify.c
|
|
get_x509_name_raw
|
3
|
14
|
24
|
gnutls_x509.c
|
|
is_issuer
|
3
|
14
|
30
|
x509/verify.c
|
|
_gnutls_openpgp_get_raw_key_expiration_time
|
3
|
14
|
27
|
openpgp/compat.c
|
|
gnutls_ocsp_req_print
|
3
|
14
|
31
|
x509/ocsp_output.c
|
|
dsa_verify_data
|
3
|
14
|
27
|
gnutls_pubkey.c
|
|
_gnutls_openpgp_get_raw_key_creation_time
|
3
|
14
|
27
|
openpgp/compat.c
|
|
write_pkcs12_kdf_params
|
3
|
14
|
37
|
x509/privkey_pkcs8.c
|
|
_gnutls_x509_encode_PKI_params
|
3
|
14
|
33
|
x509/common.c
|
|
system_recv_timeout
|
3
|
14
|
23
|
system.c
|
|
_decode_pkcs8_rsa_key
|
3
|
13
|
26
|
x509/privkey_pkcs8.c
|
|
pk_hash_data
|
3
|
13
|
28
|
gnutls_sig.c
|
|
gnutls_pkcs11_delete_url
|
3
|
13
|
29
|
pkcs11_write.c
|
|
_gnutls_x509_generalTime2gtime
|
3
|
13
|
30
|
x509/common.c
|
|
_gnutls_x509_utcTime2gtime
|
3
|
13
|
25
|
x509/common.c
|
|
keydb_cache_add
|
3
|
13
|
23
|
opencdk/keydb.c
|
|
gnutls_session_ticket_enable_client
|
3
|
13
|
26
|
ext/session_ticket.c
|
|
pack_srp_auth_info
|
3
|
13
|
24
|
gnutls_session_pack.c
|
|
gnutls_x509_crt_set_extension_by_oid
|
3
|
13
|
30
|
x509/x509_write.c
|
|
wrap_nettle_hash_init
|
3
|
13
|
26
|
nettle/mac.c
|
|
_cdk_stream_append
|
3
|
13
|
25
|
opencdk/stream.c
|
|
_gnutls_recv_supplemental
|
3
|
13
|
28
|
gnutls_handshake.c
|
|
wrap_nettle_hmac_init
|
3
|
13
|
26
|
nettle/mac.c
|
|
certificate_credential_append_crt_list
|
3
|
12
|
26
|
gnutls_x509.c
|
|
cdk_strlist_add
|
3
|
12
|
18
|
opencdk/misc.c
|
|
read_key_file
|
3
|
12
|
28
|
gnutls_x509.c
|
|
read_cert_file
|
3
|
12
|
29
|
gnutls_x509.c
|
|
_gnutls_handshake_io_cache_int
|
3
|
12
|
31
|
gnutls_buffers.c
|
|
check_b_mod_n
|
3
|
12
|
26
|
auth/srp.c
|
|
_gnutls_x509_get_raw_crt_expiration_time
|
3
|
12
|
23
|
gnutls_cert.c
|
|
gnutls_key_generate
|
3
|
12
|
23
|
crypto-api.c
|
|
_gnutls_x509_get_raw_crt_activation_time
|
3
|
12
|
23
|
gnutls_cert.c
|
|
gnutls_pkcs12_bag_set_crl
|
3
|
12
|
26
|
x509/pkcs12_bag.c
|
|
gnutls_pkcs12_bag_set_crt
|
3
|
12
|
25
|
x509/pkcs12_bag.c
|
|
_cdk_copy_pk_to_sk
|
3
|
12
|
18
|
opencdk/new-packet.c
|
|
gnutls_privkey_import_pkcs11
|
3
|
12
|
23
|
gnutls_privkey.c
|
|
gnutls_record_set_max_size
|
3
|
12
|
25
|
ext/max_record.c
|
|
check_armor
|
3
|
12
|
21
|
opencdk/armor.c
|
|
_gnutls_gen_psk_server_kx
|
3
|
12
|
27
|
auth/psk.c
|
|
gnutls_x509_crl_get_signature_algorithm
|
3
|
12
|
32
|
x509/crl.c
|
|
wrap_padlock_hash_init
|
3
|
12
|
25
|
accelerated/x86/sha-padlock.c
|
|
gnutls_x509_crt_get_preferred_hash_algorithm
|
3
|
12
|
31
|
x509/x509.c
|
|
gnutls_x509_crt_get_verify_algorithm
|
3
|
12
|
32
|
x509/x509.c
|
|
wrap_padlock_hmac_init
|
3
|
12
|
23
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_certificate_allocate_credentials
|
3
|
12
|
23
|
gnutls_cert.c
|
|
_gnutls_selected_certs_deinit
|
3
|
12
|
21
|
auth/cert.c
|
|
gnutls_openpgp_crt_set_preferred_key_id
|
3
|
12
|
26
|
openpgp/pgp.c
|
|
gnutls_pkcs11_obj_import_url
|
3
|
12
|
29
|
pkcs11.c
|
|
gnutls_alert_send
|
3
|
12
|
24
|
gnutls_alert.c
|
|
print_fingerprint
|
3
|
12
|
22
|
x509/output.c
|
|
cdk_stream_set_compress_flag
|
3
|
12
|
21
|
opencdk/stream.c
|
|
gnutls_openpgp_privkey_set_preferred_key_id
|
3
|
12
|
27
|
openpgp/privkey.c
|
|
_gnutls_x509_der_encode_and_copy
|
3
|
12
|
30
|
x509/common.c
|
|
gnutls_priority_set_direct
|
3
|
12
|
25
|
gnutls_priority.c
|
|
check_a_mod_n
|
3
|
12
|
25
|
auth/srp.c
|
|
cdk_stream_getc
|
3
|
11
|
20
|
opencdk/stream.c
|
|
_randomize_psk
|
3
|
11
|
23
|
auth/psk_passwd.c
|
|
_gnutls_x509_verify_hashed_data
|
3
|
11
|
32
|
x509/verify.c
|
|
_gnutls_x509_verify_data
|
3
|
11
|
33
|
x509/verify.c
|
|
gnutls_x509_crt_get_serial
|
3
|
11
|
25
|
x509/x509.c
|
|
gnutls_ocsp_req_init
|
3
|
11
|
22
|
x509/ocsp.c
|
|
_gnutls_log
|
3
|
11
|
20
|
gnutls_errors.c
|
|
gnutls_srp_base64_decode_alloc
|
3
|
11
|
24
|
auth/srp_sb64.c
|
|
gnutls_x509_crt_init
|
3
|
11
|
25
|
x509/x509.c
|
|
gnutls_srp_base64_encode_alloc
|
3
|
11
|
24
|
auth/srp_sb64.c
|
|
_gnutls_buffer_append_printf
|
3
|
11
|
20
|
gnutls_str.c
|
|
gnutls_system_mutex_init
|
3
|
11
|
21
|
system.c
|
|
retrieve_pin
|
3
|
11
|
29
|
pkcs11.c
|
|
stream_cache_flush
|
3
|
11
|
22
|
opencdk/stream.c
|
|
cdk_stream_set_text_flag
|
3
|
11
|
20
|
opencdk/stream.c
|
|
cdk_stream_set_armor_flag
|
3
|
11
|
20
|
opencdk/stream.c
|
|
print_key_id
|
3
|
10
|
21
|
openpgp/output.c
|
|
gnutls_pkcs11_obj_init
|
3
|
10
|
20
|
pkcs11.c
|
|
_gnutls_buffer_append_mpi
|
3
|
10
|
19
|
gnutls_str.c
|
|
gnutls_dtls_prestate_set
|
3
|
10
|
20
|
gnutls_dtls.c
|
|
_gnutls_x509_gtime2utcTime
|
3
|
10
|
23
|
x509/common.c
|
|
gnutls_openpgp_privkey_get_subkey_idx
|
3
|
10
|
23
|
openpgp/privkey.c
|
|
gnutls_pem_base64_decode_alloc
|
3
|
10
|
20
|
x509_b64.c
|
|
gnutls_x509_crq_init
|
3
|
10
|
21
|
x509/crq.c
|
|
gnutls_pkcs11_privkey_init
|
3
|
10
|
20
|
pkcs11_privkey.c
|
|
gnutls_x509_crl_get_version
|
3
|
10
|
23
|
x509/crl.c
|
|
ucs2_to_ascii
|
3
|
10
|
17
|
x509/pkcs12.c
|
|
gnutls_pem_base64_encode_alloc
|
3
|
10
|
19
|
x509_b64.c
|
|
gnutls_rehandshake
|
3
|
10
|
23
|
gnutls_handshake.c
|
|
_gnutls_srp_pack
|
3
|
10
|
18
|
ext/srp.c
|
|
gnutls_pubkey_import_x509
|
3
|
10
|
21
|
gnutls_pubkey.c
|
|
gnutls_x509_privkey_fix
|
3
|
10
|
22
|
x509/privkey.c
|
|
find_token_num
|
3
|
10
|
27
|
pkcs11.c
|
|
cdk_stream_putc
|
3
|
10
|
17
|
opencdk/stream.c
|
|
gnutls_openpgp_crt_get_subkey_idx
|
3
|
10
|
23
|
openpgp/pgp.c
|
|
_gnutls_bhash
|
3
|
36
|
52
|
hash.c
|
|
wrap_nettle_cipher_init
|
3
|
62
|
89
|
nettle/cipher.c
|
|
cdk_pkt_free
|
3
|
22
|
46
|
opencdk/new-packet.c
|
|
_pgp_hash_algo_to_gnutls
|
2
|
10
|
26
|
opencdk/misc.c
|
|
_gnutls_hash_algo_to_pgp
|
2
|
10
|
26
|
opencdk/misc.c
|
|
_ctx_init
|
2
|
45
|
60
|
nettle/mac.c
|
|
is_key_node
|
2
|
3
|
20
|
opencdk/keydb.c
|
|
wrap_nettle_hash_exists
|
2
|
2
|
16
|
nettle/mac.c
|
|
_gnutls_get_digest_oid
|
2
|
16
|
31
|
opencdk/seskey.c
|
|
schema_to_oid
|
2
|
12
|
29
|
x509/privkey_pkcs8.c
|
|
gnutls_pkcs11_type_get_name
|
2
|
6
|
20
|
pkcs11.c
|
|
_hmac_ctx_init
|
2
|
39
|
53
|
nettle/mac.c
|
|
wrap_nettle_hmac_exists
|
2
|
2
|
15
|
nettle/mac.c
|
|
set_opaque
|
2
|
13
|
28
|
opencdk/stream.c
|
|
pkcs11_rv_to_err
|
2
|
19
|
86
|
pkcs11.c
|
|
bag_to_oid
|
2
|
6
|
18
|
x509/pkcs12.c
|
|
_ctx_init
|
2
|
33
|
46
|
accelerated/x86/sha-padlock.c
|
|
_hmac_ctx_init
|
2
|
33
|
47
|
accelerated/x86/hmac-padlock.c
|
|
_cdk_pk_algo_usage
|
2
|
13
|
28
|
opencdk/pubkey.c
|
|
_gnutls_packet2str
|
2
|
5
|
17
|
debug.c
|
|
_gnutls_mre_record2num
|
2
|
5
|
18
|
ext/max_record.c
|
|
_gnutls_mre_num2record
|
2
|
5
|
17
|
ext/max_record.c
|
|
check_recv_type
|
2
|
4
|
17
|
gnutls_record.c
|
|
_gnutls_version_has_selectable_sighash
|
2
|
2
|
14
|
algorithms/protocols.c
|
|
_gnutls_version_has_selectable_prf
|
2
|
2
|
14
|
algorithms/protocols.c
|
|
cipher_to_schema
|
2
|
10
|
22
|
x509/privkey_pkcs8.c
|
|
intmode_to_char
|
2
|
5
|
17
|
opencdk/literal.c
|
|
_gnutls_asn1_encode_privkey
|
2
|
4
|
14
|
x509/key_encode.c
|
|
stream_id_to_filter
|
2
|
4
|
17
|
opencdk/stream.c
|
|
pubkey_to_bits
|
2
|
4
|
14
|
gnutls_pubkey.c
|
|
_gnutls_x509_read_pubkey_params
|
2
|
4
|
15
|
x509/key_decode.c
|
|
_gnutls_x509_write_pubkey
|
2
|
4
|
17
|
x509/key_encode.c
|
|
_gnutls_check_supported_sign_algo
|
2
|
4
|
15
|
auth/cert.c
|
|
system_errno
|
2
|
12
|
24
|
system.c
|
|
_gnutls_gen_cert_server_certificate
|
2
|
4
|
17
|
auth/cert.c
|
|
get_padsize
|
2
|
3
|
13
|
gnutls_hash_int.c
|
|
_gnutls_cert_type2num
|
2
|
3
|
14
|
ext/cert_type.c
|
|
_gnutls_num2cert_type
|
2
|
3
|
13
|
ext/cert_type.c
|
|
_cdk_map_gnutls_error
|
2
|
3
|
13
|
opencdk/misc.c
|
|
_gnutls_version_has_explicit_iv
|
2
|
2
|
13
|
algorithms/protocols.c
|
|
gnutls_openpgp_keyring_check_id
|
2
|
9
|
20
|
openpgp/extras.c
|
|
_pkcs12_bag_free_data
|
2
|
9
|
15
|
x509/pkcs12_bag.c
|
|
gnutls_safe_renegotiation_status
|
2
|
9
|
19
|
ext/safe_renegotiation.c
|
|
_gnutls_server_name_pack
|
2
|
9
|
15
|
ext/server_name.c
|
|
_gnutls_ext_register
|
2
|
9
|
20
|
gnutls_extensions.c
|
|
_gnutls_mac_reset_ssl3
|
2
|
9
|
18
|
gnutls_hash_int.c
|
|
mpi_buf2bits
|
2
|
9
|
18
|
gnutls_ui.c
|
|
_gnutls_buffer_insert_data
|
2
|
9
|
18
|
gnutls_str.c
|
|
_gnutls_tls_create_random
|
2
|
9
|
24
|
gnutls_handshake.c
|
|
_mbuffer_alloc
|
2
|
9
|
19
|
gnutls_mbuffers.c
|
|
gnutls_ocsp_resp_get_signature_algorithm
|
2
|
9
|
20
|
x509/ocsp.c
|
|
wrap_nettle_hmac_fast
|
2
|
9
|
17
|
nettle/mac.c
|
|
_gnutls_x509_get_signature_algorithm
|
2
|
9
|
24
|
x509/common.c
|
|
cryptodev_decrypt
|
2
|
9
|
18
|
accelerated/cryptodev.c
|
|
cryptodev_encrypt
|
2
|
9
|
16
|
accelerated/cryptodev.c
|
|
gnutls_x509_dn_import
|
2
|
8
|
18
|
x509/dn.c
|
|
cryptodev_cipher_setkey
|
2
|
8
|
17
|
accelerated/cryptodev.c
|
|
_mbuffer_enqueue
|
2
|
8
|
15
|
gnutls_mbuffers.c
|
|
_cdk_pkt_write_fp
|
2
|
8
|
13
|
opencdk/write-packet.c
|
|
do_trivia_source
|
2
|
8
|
27
|
nettle/rnd.c
|
|
filter_add2
|
2
|
8
|
14
|
opencdk/stream.c
|
|
_cdk_buftou32
|
2
|
8
|
13
|
opencdk/misc.c
|
|
wrap_nettle_hash_fast
|
2
|
8
|
16
|
nettle/mac.c
|
|
signature_algorithms_pack
|
2
|
8
|
13
|
ext/signature.c
|
|
cryptodev_mac_setkey
|
2
|
8
|
17
|
accelerated/cryptodev.c
|
|
_gnutls_x509_write_uint32
|
2
|
8
|
18
|
x509/mpi.c
|
|
_cdk_s2k_copy
|
2
|
8
|
14
|
opencdk/seskey.c
|
|
gnutls_global_set_mem_functions
|
2
|
8
|
26
|
gnutls_global.c
|
|
_deregister
|
2
|
8
|
16
|
crypto-backend.c
|
|
calc_mpisize
|
2
|
7
|
10
|
opencdk/write-packet.c
|
|
gnutls_x509_dn_init
|
2
|
7
|
18
|
x509/dn.c
|
|
_cdk_free_userid
|
2
|
7
|
12
|
opencdk/new-packet.c
|
|
wrap_nettle_mpi_new
|
2
|
7
|
15
|
nettle/mpi.c
|
|
_gnutls_cipher_suite_is_ok
|
2
|
7
|
14
|
algorithms/ciphersuites.c
|
|
_mbuffer_head_clear
|
2
|
7
|
13
|
gnutls_mbuffers.c
|
|
read_16
|
2
|
7
|
13
|
opencdk/read-packet.c
|
|
_gnutls_epoch_refcount_inc
|
2
|
7
|
13
|
gnutls_constate.h
|
|
gnutls_x509_crq_set_attribute_by_oid
|
2
|
7
|
19
|
x509/crq.c
|
|
gnutls_certificate_get_peers
|
2
|
7
|
15
|
gnutls_ui.c
|
|
read_32
|
2
|
7
|
13
|
opencdk/read-packet.c
|
|
_gnutls_io_write_buffered
|
2
|
7
|
22
|
gnutls_buffers.c
|
|
stream_read
|
2
|
7
|
13
|
opencdk/write-packet.c
|
|
wrap_nettle_hash_output
|
2
|
7
|
16
|
nettle/mac.c
|
|
gnutls_hex_encode
|
2
|
7
|
17
|
gnutls_psk.c
|
|
_gnutls_cipher_exists
|
2
|
7
|
11
|
gnutls_cipher_int.c
|
|
mp_clear_multi
|
2
|
7
|
12
|
nettle/multi.c
|
|
_gnutls_generate_session_id
|
2
|
7
|
16
|
gnutls_handshake.c
|
|
wrap_padlock_hmac_output
|
2
|
7
|
16
|
accelerated/x86/hmac-padlock.c
|
|
wrap_nettle_hmac_output
|
2
|
7
|
16
|
nettle/mac.c
|
|
_gnutls_x509_sign_to_oid
|
2
|
7
|
14
|
algorithms/sign.c
|
|
gnutls_openpgp_crt_get_subkey_pk_dsa_raw
|
2
|
7
|
20
|
openpgp/pgp.c
|
|
gnutls_openpgp_crt_get_subkey_pk_rsa_raw
|
2
|
7
|
18
|
openpgp/pgp.c
|
|
gnutls_openpgp_crt_get_pk_dsa_raw
|
2
|
7
|
17
|
openpgp/pgp.c
|
|
gnutls_openpgp_crt_get_pk_rsa_raw
|
2
|
7
|
16
|
openpgp/pgp.c
|
|
gnutls_openpgp_privkey_sec_param
|
2
|
7
|
15
|
openpgp/privkey.c
|
|
gnutls_openpgp_privkey_export_subkey_dsa_raw
|
2
|
7
|
21
|
openpgp/privkey.c
|
|
gnutls_openpgp_privkey_export_subkey_rsa_raw
|
2
|
7
|
22
|
openpgp/privkey.c
|
|
gnutls_openpgp_privkey_export_dsa_raw
|
2
|
7
|
18
|
openpgp/privkey.c
|
|
gnutls_openpgp_privkey_export_rsa_raw
|
2
|
7
|
18
|
openpgp/privkey.c
|
|
certificate_credentials_append_pkey
|
2
|
6
|
16
|
gnutls_x509.c
|
|
gnutls_x509_crl_verify
|
2
|
6
|
18
|
x509/verify.c
|
|
proc_anon_ecdh_client_kx
|
2
|
6
|
17
|
auth/anon_ecdh.c
|
|
disable_optional_stuff
|
2
|
6
|
16
|
x509/x509_write.c
|
|
_gnutls_datum_append_m
|
2
|
6
|
15
|
gnutls_datum.c
|
|
gnutls_rsa_params_init
|
2
|
6
|
14
|
gnutls_rsa_export.c
|
|
gnutls_cipher_get
|
2
|
6
|
12
|
gnutls_state.c
|
|
free_record_state
|
2
|
6
|
12
|
gnutls_constate.c
|
|
_gnutls_handshake_recv_buffer_init
|
2
|
6
|
9
|
gnutls_buffers.h
|
|
_gnutls_strdup
|
2
|
6
|
11
|
gnutls_mem.c
|
|
_gnutls_handshake_recv_buffer_clear
|
2
|
6
|
7
|
gnutls_buffers.h
|
|
cdk_strlist_free
|
2
|
6
|
11
|
opencdk/misc.c
|
|
epoch_get_slot
|
2
|
6
|
14
|
gnutls_constate.c
|
|
free_pubkey_enc
|
2
|
6
|
12
|
opencdk/new-packet.c
|
|
gnutls_srp_server_get_username
|
2
|
6
|
12
|
gnutls_srp.c
|
|
_gnutls_epoch_get_compression
|
2
|
6
|
11
|
gnutls_constate.c
|
|
_cdk_u32tobuf
|
2
|
6
|
10
|
opencdk/misc.c
|
|
keydb_cache_free
|
2
|
6
|
13
|
opencdk/keydb.c
|
|
gnutls_pk_params_release
|
2
|
6
|
10
|
gnutls_pk.c
|
|
_gnutls_epoch_is_valid
|
2
|
6
|
11
|
gnutls_constate.h
|
|
gnutls_x509_privkey_init
|
2
|
6
|
14
|
x509/privkey.c
|
|
_gnutls_str_array_clear
|
2
|
6
|
12
|
gnutls_str_array.h
|
|
uid_list_free
|
2
|
6
|
13
|
opencdk/sig-check.c
|
|
cdk_kbnode_new
|
2
|
6
|
11
|
opencdk/kbnode.c
|
|
gnutls_pkcs11_privkey_export_url
|
2
|
6
|
16
|
pkcs11_privkey.c
|
|
wrap_padlock_hash_output
|
2
|
6
|
13
|
accelerated/x86/sha-padlock.c
|
|
_gnutls_dump_mpi
|
2
|
6
|
13
|
debug.c
|
|
_mbuffer_append_data
|
2
|
6
|
16
|
gnutls_mbuffers.c
|
|
gnutls_alert_send_appropriate
|
2
|
6
|
14
|
gnutls_alert.c
|
|
gnutls_ecc_curve_get_size
|
2
|
6
|
14
|
algorithms/ecc.c
|
|
_gnutls_ecc_curve_get_params
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
_gnutls_cipher_is_ok
|
2
|
6
|
11
|
algorithms/ciphers.c
|
|
_gnutls_file_exists
|
2
|
6
|
12
|
gnutls_helper.c
|
|
_gnutls_ecc_curve_get_oid
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
gnutls_pubkey_get_preferred_hash_algorithm
|
2
|
6
|
19
|
gnutls_pubkey.c
|
|
gnutls_ecc_curve_get_name
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
_gnutls_kx_is_ok
|
2
|
6
|
11
|
algorithms/kx.c
|
|
_gnutls_mac_is_ok
|
2
|
6
|
11
|
algorithms/mac.c
|
|
gnutls_cipher_get_id
|
2
|
6
|
15
|
algorithms/ciphers.c
|
|
gnutls_kx_list
|
2
|
6
|
15
|
algorithms/kx.c
|
|
_gnutls_ecc_bits_to_curve
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
wrap_nettle_mpi_set_ui
|
2
|
6
|
14
|
nettle/mpi.c
|
|
_gnutls_compression_is_ok
|
2
|
6
|
11
|
gnutls_compress.c
|
|
gnutls_kx_get_id
|
2
|
6
|
15
|
algorithms/kx.c
|
|
_gnutls_ecc_curve_get_id
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
gnutls_pkcs11_obj_export_url
|
2
|
6
|
15
|
pkcs11.c
|
|
wrap_nettle_mpi_set
|
2
|
6
|
13
|
nettle/mpi.c
|
|
gnutls_protocol_list
|
2
|
6
|
15
|
algorithms/protocols.c
|
|
gnutls_compression_get
|
2
|
6
|
12
|
gnutls_state.c
|
|
gnutls_system_mutex_init
|
2
|
6
|
14
|
system.c
|
|
_gnutls_oid_to_ecc_curve
|
2
|
6
|
14
|
algorithms/ecc.c
|
|
gnutls_sign_get_id
|
2
|
6
|
16
|
algorithms/sign.c
|
|
gnutls_protocol_get_id
|
2
|
6
|
15
|
algorithms/protocols.c
|
|
gnutls_x509_privkey_verify_params
|
2
|
6
|
14
|
x509/privkey.c
|
|
gnutls_mac_get
|
2
|
6
|
12
|
gnutls_state.c
|
|
gnutls_sec_param_get_name
|
2
|
6
|
13
|
algorithms/secparams.c
|
|
_gnutls_ecc_curve_get_tls_id
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
gnutls_sign_list
|
2
|
6
|
15
|
algorithms/sign.c
|
|
gnutls_pk_algorithm_get_name
|
2
|
6
|
15
|
algorithms/publickey.c
|
|
_gnutls_pk_bits_to_subgroup_bits
|
2
|
6
|
13
|
algorithms/secparams.c
|
|
_gnutls_tls_id_to_ecc_curve
|
2
|
6
|
15
|
algorithms/ecc.c
|
|
gnutls_mac_get_id
|
2
|
6
|
15
|
algorithms/mac.c
|
|
_cdk_kbnode_add
|
2
|
6
|
9
|
opencdk/kbnode.c
|
|
gnutls_x509_privkey_sec_param
|
2
|
5
|
11
|
x509/privkey.c
|
|
gnutls_cipher_tag
|
2
|
5
|
12
|
crypto-api.c
|
|
_mbuffer_consume
|
2
|
5
|
11
|
gnutls_mbuffers.h
|
|
_gnutls_cal_PRF_A
|
2
|
5
|
13
|
gnutls_state.c
|
|
cdk_subpkt_init
|
2
|
5
|
10
|
opencdk/new-packet.c
|
|
handshake_compare
|
2
|
5
|
10
|
gnutls_buffers.c
|
|
gnutls_cipher_suite_get_name
|
2
|
5
|
13
|
algorithms/ciphersuites.c
|
|
gnutls_x509_privkey_deinit
|
2
|
5
|
10
|
x509/privkey.c
|
|
cdk_subpkt_free
|
2
|
5
|
12
|
opencdk/new-packet.c
|
|
gnutls_dtls_get_data_mtu
|
2
|
5
|
10
|
gnutls_dtls.c
|
|
gnutls_crypto_digest_register
|
2
|
5
|
13
|
crypto-backend.c
|
|
gnutls_crypto_mac_register
|
2
|
5
|
13
|
crypto-backend.c
|
|
gnutls_hash_init
|
2
|
5
|
12
|
crypto-api.c
|
|
gnutls_rsa_export_get_modulus_bits
|
2
|
5
|
11
|
gnutls_ui.c
|
|
_gnutls_mac_deinit_ssl3
|
2
|
5
|
10
|
gnutls_hash_int.c
|
|
wrap_nettle_prime_check
|
2
|
5
|
13
|
nettle/mpi.c
|
|
gnutls_hex_decode
|
2
|
5
|
14
|
gnutls_psk.c
|
|
gnutls_crypto_cipher_register
|
2
|
5
|
13
|
crypto-backend.c
|
|
gnutls_crypto_pk_register
|
2
|
5
|
13
|
crypto-backend.c
|
|
stream_write
|
2
|
5
|
10
|
opencdk/write-packet.c
|
|
gnutls_crypto_bigint_register
|
2
|
5
|
13
|
crypto-backend.c
|
|
gnutls_hmac_init
|
2
|
5
|
14
|
crypto-api.c
|
|
gnutls_privkey_init
|
2
|
5
|
12
|
gnutls_privkey.c
|
|
gnutls_cipher_deinit
|
2
|
5
|
10
|
crypto-api.c
|
|
_gnutls_map_kx_get_kx
|
2
|
5
|
15
|
algorithms/kx.c
|
|
gnutls_psk_set_server_credentials_hint
|
2
|
5
|
13
|
gnutls_psk.c
|
|
remove_front
|
2
|
5
|
11
|
gnutls_mbuffers.c
|
|
_gnutls_hmac_exists
|
2
|
5
|
9
|
gnutls_hash_int.c
|
|
wrap_nettle_mpi_mod
|
2
|
5
|
12
|
nettle/mpi.c
|
|
gnutls_crypto_rnd_register
|
2
|
5
|
13
|
crypto-backend.c
|
|
_gnutls_send_hello
|
2
|
5
|
17
|
gnutls_handshake.c
|
|
_gnutls_check_key_cert_match
|
2
|
5
|
14
|
gnutls_x509.c
|
|
_gnutls_mpi_scan_pgp
|
2
|
5
|
13
|
gnutls_mpi.c
|
|
_dtls_retransmit
|
2
|
5
|
13
|
gnutls_dtls.c
|
|
_mbuffer_head_pop_first
|
2
|
5
|
12
|
gnutls_mbuffers.c
|
|
get_errno
|
2
|
5
|
12
|
gnutls_buffers.c
|
|
gnutls_pubkey_init
|
2
|
5
|
12
|
gnutls_pubkey.c
|
|
_gnutls_mpi_scan
|
2
|
5
|
13
|
gnutls_mpi.c
|
|
gnutls_dh_params_deinit
|
2
|
5
|
12
|
gnutls_dh_primes.c
|
|
gnutls_x509_dn_export
|
2
|
5
|
17
|
x509/dn.c
|
|
gnutls_cipher_add_auth
|
2
|
5
|
12
|
crypto-api.c
|
|
_gnutls_session_is_export
|
2
|
5
|
14
|
gnutls_state.c
|
|
_gnutls_handshake_alloc
|
2
|
5
|
13
|
gnutls_mbuffers.h
|
|
gnutls_dh_params_init
|
2
|
5
|
14
|
gnutls_dh_primes.c
|
|
aes_gcm_setiv
|
2
|
5
|
12
|
accelerated/x86/aes-gcm-padlock.c
|
|
gnutls_compression_get_id
|
2
|
4
|
12
|
gnutls_compress.c
|
|
gnutls_x509_privkey_get_pk_algorithm
|
2
|
4
|
11
|
x509/privkey.c
|
|
gnutls_x509_crt_set_expiration_time
|
2
|
4
|
11
|
x509/x509_write.c
|
|
gnutls_pkcs12_bag_deinit
|
2
|
4
|
10
|
x509/pkcs12_bag.c
|
|
gnutls_x509_crt_set_activation_time
|
2
|
4
|
13
|
x509/x509_write.c
|
|
_gnutls_hmac_output
|
2
|
4
|
12
|
gnutls_hash_int.h
|
|
stream_get_mode
|
2
|
4
|
9
|
opencdk/stream.c
|
|
gnutls_x509_crq_get_attribute_by_oid
|
2
|
4
|
14
|
x509/crq.c
|
|
gnutls_x509_crl_export
|
2
|
4
|
14
|
x509/crl.c
|
|
gnutls_psk_allocate_client_credentials
|
2
|
4
|
10
|
gnutls_psk.c
|
|
stream_putc
|
2
|
4
|
8
|
opencdk/write-packet.c
|
|
gnutls_x509_crt_get_expiration_time
|
2
|
4
|
12
|
x509/x509.c
|
|
_dtls_async_timer_delete
|
2
|
4
|
9
|
gnutls_dtls.h
|
|
gnutls_x509_crt_get_activation_time
|
2
|
4
|
12
|
x509/x509.c
|
|
gnutls_srp_allocate_server_credentials
|
2
|
4
|
10
|
gnutls_srp.c
|
|
_gnutls_connection_state_init
|
2
|
4
|
12
|
gnutls_constate.c
|
|
gnutls_pkcs12_bag_init
|
2
|
4
|
11
|
x509/pkcs12_bag.c
|
|
_dtls_async_timer_init
|
2
|
4
|
10
|
gnutls_dtls.h
|
|
gnutls_openpgp_keyring_init
|
2
|
4
|
9
|
openpgp/extras.c
|
|
gnutls_x509_crt_get_dn_oid
|
2
|
4
|
14
|
x509/x509.c
|
|
gnutls_openpgp_privkey_init
|
2
|
4
|
9
|
openpgp/privkey.c
|
|
gnutls_x509_crl_get_next_update
|
2
|
4
|
11
|
x509/crl.c
|
|
gnutls_openpgp_crt_init
|
2
|
4
|
9
|
openpgp/pgp.c
|
|
gnutls_x509_crq_get_challenge_password
|
2
|
4
|
13
|
x509/crq.c
|
|
gnutls_srp_allocate_client_credentials
|
2
|
4
|
10
|
gnutls_srp.c
|
|
gnutls_x509_crt_get_dn_by_oid
|
2
|
4
|
15
|
x509/x509.c
|
|
gnutls_x509_crl_get_this_update
|
2
|
4
|
11
|
x509/crl.c
|
|
gnutls_x509_crt_get_dn
|
2
|
4
|
14
|
x509/x509.c
|
|
gnutls_x509_crt_get_issuer_dn_oid
|
2
|
4
|
14
|
x509/x509.c
|
|
gnutls_x509_crt_get_issuer_dn_by_oid
|
2
|
4
|
16
|
x509/x509.c
|
|
_gnutls_register_accel_crypto
|
2
|
4
|
12
|
accelerated/accelerated.c
|
|
gnutls_pkcs12_export
|
2
|
4
|
14
|
x509/pkcs12.c
|
|
gnutls_x509_crt_get_issuer_dn
|
2
|
4
|
14
|
x509/x509.c
|
|
gnutls_x509_crq_get_dn_oid
|
2
|
4
|
14
|
x509/crq.c
|
|
cdk_pkt_release
|
2
|
4
|
8
|
opencdk/new-packet.c
|
|
gnutls_x509_crl_get_dn_oid
|
2
|
4
|
14
|
x509/crl.c
|
|
gnutls_system_mutex_unlock
|
2
|
4
|
11
|
system.c
|
|
cdk_kbnode_find_packet
|
2
|
4
|
8
|
opencdk/kbnode.c
|
|
gnutls_x509_crq_get_dn_by_oid
|
2
|
4
|
16
|
x509/crq.c
|
|
gnutls_system_mutex_lock
|
2
|
4
|
11
|
system.c
|
|
gnutls_x509_crl_get_issuer_dn_by_oid
|
2
|
4
|
16
|
x509/crl.c
|
|
gnutls_x509_crt_export
|
2
|
4
|
14
|
x509/x509.c
|
|
get_dn
|
2
|
4
|
8
|
x509/x509.c
|
|
gnutls_x509_crl_set_next_update
|
2
|
4
|
10
|
x509/crl_write.c
|
|
gnutls_cipher_decrypt
|
2
|
4
|
11
|
crypto-api.c
|
|
gnutls_x509_crq_get_dn
|
2
|
4
|
13
|
x509/crq.c
|
|
gnutls_x509_crl_get_issuer_dn
|
2
|
4
|
14
|
x509/crl.c
|
|
gnutls_protocol_set_priority
|
2
|
4
|
13
|
gnutls_priority.c
|
|
gnutls_psk_allocate_server_credentials
|
2
|
4
|
10
|
gnutls_psk.c
|
|
gnutls_x509_crl_set_this_update
|
2
|
4
|
11
|
x509/crl_write.c
|
|
gnutls_pubkey_deinit
|
2
|
4
|
8
|
gnutls_pubkey.c
|
|
gnutls_pubkey_get_verify_algorithm
|
2
|
4
|
17
|
gnutls_pubkey.c
|
|
gnutls_cipher_set_iv
|
2
|
4
|
10
|
crypto-api.c
|
|
gnutls_pkcs12_bag_get_count
|
2
|
4
|
11
|
x509/pkcs12_bag.c
|
|
_gnutls_hash_output
|
2
|
4
|
12
|
gnutls_hash_int.h
|
|
_asnstr_append_name
|
2
|
4
|
12
|
x509/common.c
|
|
_gnutls_mpi_release
|
2
|
4
|
9
|
gnutls_mpi.c
|
|
gnutls_x509_crq_export
|
2
|
4
|
14
|
x509/crq.c
|
|
_gnutls_free_datum_m
|
2
|
4
|
9
|
gnutls_datum.c
|
|
_gnutls_hmac_reset
|
2
|
3
|
10
|
gnutls_hash_int.h
|
|
gnutls_pubkey_get_pk_algorithm
|
2
|
3
|
8
|
gnutls_pubkey.c
|
|
gnutls_pkcs11_privkey_get_pk_algorithm
|
2
|
3
|
8
|
pkcs11_privkey.c
|
|
_dtls_async_timer_active
|
2
|
3
|
7
|
gnutls_dtls.h
|
|
system_errno
|
2
|
3
|
9
|
system.c
|
|
gnutls_sign_callback_get
|
2
|
3
|
7
|
gnutls_cert.c
|
|
free_literal
|
2
|
3
|
9
|
opencdk/new-packet.c
|
|
_gnutls_generate_master
|
2
|
3
|
7
|
gnutls_kx.c
|
|
_gnutls_hmac
|
2
|
3
|
9
|
gnutls_hash_int.h
|
|
is_supported_curve
|
2
|
3
|
7
|
nettle/pk.c
|
|
is_read_comp_null
|
2
|
3
|
8
|
gnutls_cipher.c
|
|
_gnutls_write_datum8
|
2
|
3
|
7
|
gnutls_datum.c
|
|
is_write_comp_null
|
2
|
3
|
8
|
gnutls_cipher.c
|
|
ecc_del_point
|
2
|
3
|
10
|
nettle/ecc_points.c
|
|
_gnutls_write_datum32
|
2
|
3
|
7
|
gnutls_datum.c
|
|
_gnutls_rnd_deinit
|
2
|
3
|
10
|
random.c
|
|
gnutls_pkcs7_export
|
2
|
3
|
11
|
x509/pkcs7.c
|
|
_gnutls_write_datum24
|
2
|
3
|
7
|
gnutls_datum.c
|
|
stream_read
|
2
|
3
|
6
|
opencdk/read-packet.c
|
|
cdk_pk_from_secret_key
|
2
|
3
|
7
|
opencdk/pubkey.c
|
|
cdk_kbnode_get_packet
|
2
|
3
|
7
|
opencdk/kbnode.c
|
|
_cdk_stream_set_compress_algo
|
2
|
3
|
7
|
opencdk/stream.c
|
|
_gnutls_rsa_params_to_mpi
|
2
|
3
|
10
|
gnutls_rsa_export.c
|
|
cdk_stream_is_compressed
|
2
|
3
|
7
|
opencdk/stream.c
|
|
_gnutls_pk_fixup
|
2
|
3
|
8
|
gnutls_pk.h
|
|
_gnutls_write_datum16
|
2
|
3
|
7
|
gnutls_datum.c
|
|
_gnutls_rnd
|
2
|
3
|
9
|
random.h
|
|
disable_optional_stuff
|
2
|
3
|
11
|
x509/crl_write.c
|
|
check_if_clean
|
2
|
3
|
7
|
gnutls_privkey.c
|
|
_gnutls_read
|
2
|
3
|
10
|
gnutls_buffers.c
|
|
sequence_increment
|
2
|
3
|
13
|
gnutls_record.c
|
|
session_is_valid
|
2
|
3
|
8
|
gnutls_record.c
|
|
pkt_write_head
|
2
|
3
|
7
|
opencdk/write-packet.c
|
|
_gnutls_get_kx_cred
|
2
|
3
|
9
|
gnutls_auth.c
|
|
gnutls_auth_get_type
|
2
|
3
|
14
|
gnutls_auth.c
|
|
print_other
|
2
|
3
|
9
|
x509/output.c
|
|
_gnutls_hash_reset
|
2
|
3
|
10
|
gnutls_hash_int.h
|
|
_mbuffer_xfree
|
2
|
3
|
8
|
gnutls_mbuffers.h
|
|
gnutls_pubkey_get_key_usage
|
2
|
3
|
8
|
gnutls_pubkey.c
|
|
gnutls_session_resumption_requested
|
2
|
3
|
12
|
gnutls_state.c
|
|
_gnutls_hash
|
2
|
3
|
9
|
gnutls_hash_int.h
|
|
cdk_kbnode_delete
|
2
|
2
|
6
|
opencdk/kbnode.c
|
|
_cdk_stream_get_errno
|
2
|
2
|
5
|
opencdk/stream.c
|
|
_cdk_stream_get_fp
|
2
|
2
|
5
|
opencdk/stream.c
|
|
_cdk_kbnode_clone
|
2
|
2
|
8
|
opencdk/kbnode.c
|
|
cdk_stream_eof
|
2
|
2
|
5
|
opencdk/stream.c
|
|
_cdk_free_mpibuf
|
2
|
2
|
8
|
opencdk/new-packet.c
|
|
_gnutls_version_has_extensions
|
2
|
2
|
15
|
algorithms/protocols.c
|
|
_cdk_stream_get_blockmode
|
2
|
2
|
5
|
opencdk/stream.c
|
|
cdk_stream_tell
|
2
|
2
|
5
|
opencdk/stream.c
|
|
_gnutls_srp_unpack
|
2
|
18
|
33
|
ext/srp.c
|
|
session_ticket_unpack
|
2
|
17
|
29
|
ext/session_ticket.c
|
|
make_preamble
|
2
|
17
|
26
|
gnutls_cipher.c
|
|
digest_ticket
|
2
|
14
|
25
|
ext/session_ticket.c
|
|
pack_anon_auth_info
|
2
|
13
|
26
|
gnutls_session_pack.c
|
|
_cdk_stream_fpopen
|
2
|
13
|
22
|
opencdk/stream.c
|
|
ecc_make_key
|
2
|
13
|
27
|
nettle/ecc_make_key.c
|
|
aes_gcm_setiv
|
2
|
13
|
22
|
accelerated/x86/aes-gcm-x86.c
|
|
cryptodev_cipher_init
|
2
|
12
|
22
|
accelerated/cryptodev.c
|
|
cdk_sk_release
|
2
|
12
|
18
|
opencdk/new-packet.c
|
|
stream_fp_replace
|
2
|
11
|
20
|
opencdk/stream.c
|
|
gnutls_x509_crt_get_issuer_unique_id
|
2
|
11
|
27
|
x509/x509.c
|
|
gnutls_x509_crt_get_subject_unique_id
|
2
|
11
|
27
|
x509/x509.c
|
|
cryptodev_mac_init
|
2
|
11
|
22
|
accelerated/cryptodev.c
|
|
gnutls_certificate_set_x509_simple_pkcs12_file
|
2
|
11
|
24
|
gnutls_x509.c
|
|
aes_gcm_cipher_setkey
|
2
|
10
|
20
|
accelerated/x86/aes-gcm-x86.c
|
|
gnutls_openpgp_crt_print
|
2
|
10
|
25
|
openpgp/output.c
|
|
overwrite_attribute
|
2
|
10
|
22
|
x509/crq.c
|
|
cryptodev_mac_output
|
2
|
10
|
17
|
accelerated/cryptodev.c
|
|
cryptodev_mac_hash
|
2
|
10
|
16
|
accelerated/cryptodev.c
|
|
wrap_padlock_hash_copy
|
2
|
10
|
20
|
accelerated/x86/sha-padlock.c
|
|
gnutls_global_deinit
|
2
|
10
|
18
|
gnutls_global.c
|
|
wrap_nettle_hash_copy
|
2
|
10
|
20
|
nettle/mac.c
|
|
gnutls_dh_params_generate2
|
2
|
10
|
19
|
gnutls_dh_primes.c
|
|
mp_init_multi
|
2
|
10
|
15
|
nettle/multi.c
|
|
cdk_pk_release
|
2
|
10
|
16
|
opencdk/new-packet.c
|
|
_gnutls_handshake2str
|
2
|
31
|
56
|
debug.c
|
|
_gnutls_asn2err
|
2
|
15
|
37
|
gnutls_errors.c
|
|
wrap_nettle_cipher_exists
|
2
|
2
|
21
|
nettle/cipher.c
|
|
digest_length
|
2
|
9
|
27
|
gnutls_hash_int.c
|
|
_gnutls_cipher_to_pgp
|
2
|
11
|
29
|
opencdk/misc.c
|
|
_pgp_cipher_to_gnutls
|
2
|
11
|
29
|
opencdk/misc.c
|
|
_gnutls_map_cdk_rc
|
2
|
10
|
27
|
openpgp/gnutls_openpgp.c
|
|
padlock_sha256_digest
|
1
|
9
|
24
|
accelerated/x86/sha-padlock.c
|
|
padlock_sha1_digest
|
1
|
9
|
21
|
accelerated/x86/sha-padlock.c
|
|
pkcs11_call_token_func
|
1
|
8
|
14
|
pkcs11.c
|
|
gnutls_x509_crl_print
|
1
|
8
|
20
|
x509/output.c
|
|
_gnutls_read_uint24
|
1
|
8
|
16
|
gnutls_num.c
|
|
_gnutls_hash_copy
|
1
|
7
|
14
|
gnutls_hash_int.c
|
|
_rsa_params_to_privkey
|
1
|
6
|
12
|
nettle/pk.c
|
|
write_32
|
1
|
6
|
11
|
opencdk/write-packet.c
|
|
_gnutls_max_record_unpack
|
1
|
6
|
15
|
ext/max_record.c
|
|
_gnutls_write_uint24
|
1
|
6
|
14
|
gnutls_num.c
|
|
_gnutls_uint24touint32
|
1
|
5
|
10
|
gnutls_num.c
|
|
append
|
1
|
5
|
8
|
gnutls_str_array.h
|
|
_gnutls_record_buffer_put
|
1
|
5
|
14
|
gnutls_buffers.c
|
|
session_ticket_pack
|
1
|
5
|
11
|
ext/session_ticket.c
|
|
wrap_nettle_rnd_deinit
|
1
|
5
|
10
|
nettle/rnd.c
|
|
millisleep
|
1
|
5
|
12
|
system.h
|
|
_gnutls_buffer_pop_data
|
1
|
5
|
13
|
gnutls_str.c
|
|
_gnutls_selected_certs_set
|
1
|
5
|
13
|
auth/cert.c
|
|
gnutls_certificate_free_credentials
|
1
|
5
|
13
|
gnutls_cert.c
|
|
ctr_encrypt_last
|
1
|
5
|
13
|
accelerated/x86/aes-gcm-x86.c
|
|
padlock_aes_cbc_decrypt
|
1
|
5
|
13
|
accelerated/x86/aes-padlock.c
|
|
wrap_nettle_rnd_deinit
|
1
|
5
|
10
|
nettle/rnd.c
|
|
padlock_aes_cbc_encrypt
|
1
|
5
|
13
|
accelerated/x86/aes-padlock.c
|
|
aes_setiv
|
1
|
5
|
12
|
accelerated/x86/aes-padlock.c
|
|
_gnutls_uint32touint24
|
1
|
5
|
11
|
gnutls_num.c
|
|
gnutls_sign_get_name
|
1
|
4
|
11
|
algorithms/sign.c
|
|
write_16
|
1
|
4
|
9
|
opencdk/write-packet.c
|
|
_gnutls_epoch_free
|
1
|
4
|
10
|
gnutls_constate.c
|
|
_gnutls_handshake_hash_buffer_empty
|
1
|
4
|
10
|
gnutls_handshake.c
|
|
_dsa_params_to_pubkey
|
1
|
4
|
9
|
nettle/pk.c
|
|
_mbuffer_head_init
|
1
|
4
|
9
|
gnutls_mbuffers.c
|
|
padlock_aes_encrypt
|
1
|
4
|
11
|
accelerated/x86/aes-gcm-padlock.c
|
|
_gnutls_free_dh_info
|
1
|
4
|
8
|
auth/dh_common.c
|
|
gnutls_pcert_deinit
|
1
|
4
|
8
|
gnutls_pcert.c
|
|
wrap_padlock_hmac_setkey
|
1
|
4
|
11
|
accelerated/x86/hmac-padlock.c
|
|
aes_gcm_auth
|
1
|
4
|
10
|
accelerated/x86/aes-gcm-x86.c
|
|
_gnutls_uint64touint32
|
1
|
4
|
12
|
gnutls_num.c
|
|
wrap_nettle_hmac_setkey
|
1
|
4
|
11
|
nettle/mac.c
|
|
_gnutls_srp_deinit_data
|
1
|
4
|
9
|
ext/srp.c
|
|
_gnutls_read_uint16
|
1
|
4
|
10
|
gnutls_num.c
|
|
_cdk_stream_set_blockmode
|
1
|
4
|
10
|
opencdk/stream.c
|
|
_gnutls_read_uint32
|
1
|
4
|
11
|
gnutls_num.c
|
|
cdk_stream_mmap
|
1
|
4
|
10
|
opencdk/stream.c
|
|
aes_decrypt
|
1
|
3
|
10
|
accelerated/x86/aes-x86.c
|
|
aes_gcm_cipher_setkey
|
1
|
3
|
9
|
accelerated/x86/aes-gcm-padlock.c
|
|
_gnutls_buffer_init
|
1
|
3
|
7
|
gnutls_str.c
|
|
aes_encrypt
|
1
|
3
|
9
|
accelerated/x86/aes-x86.c
|
|
gnutls_mac_get_name
|
1
|
3
|
10
|
algorithms/mac.c
|
|
_gnutls_handshake_buffer_move
|
1
|
3
|
6
|
gnutls_buffers.c
|
|
aes_setiv
|
1
|
3
|
8
|
accelerated/x86/aes-x86.c
|
|
gnutls_compression_get_name
|
1
|
3
|
10
|
gnutls_compress.c
|
|
gnutls_pkcs11_obj_deinit
|
1
|
3
|
7
|
pkcs11.c
|
|
_gnutls_cipher_suite_get_name
|
1
|
3
|
10
|
algorithms/ciphersuites.c
|
|
_gnutls_cipher_suite_get_mac_algo
|
1
|
3
|
8
|
algorithms/ciphersuites.c
|
|
_gnutls_handshake_buffer_init
|
1
|
3
|
6
|
gnutls_buffers.h
|
|
_gnutls_cipher_suite_get_prf
|
1
|
3
|
9
|
algorithms/ciphersuites.c
|
|
_gnutls_cipher_suite_get_kx_algo
|
1
|
3
|
9
|
algorithms/ciphersuites.c
|
|
_gnutls_cipher_suite_get_cipher_algo
|
1
|
3
|
7
|
algorithms/ciphersuites.c
|
|
padlock_aes_set_encrypt_key
|
1
|
3
|
8
|
accelerated/x86/aes-gcm-padlock.c
|
|
wrap_padlock_hash_update
|
1
|
3
|
9
|
accelerated/x86/sha-padlock.c
|
|
gnutls_srp_free_server_credentials
|
1
|
3
|
8
|
gnutls_srp.c
|
|
_gnutls_set_resumed_parameters
|
1
|
3
|
9
|
gnutls_constate.c
|
|
gnutls_psk_free_client_credentials
|
1
|
3
|
7
|
gnutls_psk.c
|
|
wrap_nettle_hash_reset
|
1
|
3
|
8
|
nettle/mac.c
|
|
session_ticket_deinit_data
|
1
|
3
|
8
|
ext/session_ticket.c
|
|
gnutls_srp_free_client_credentials
|
1
|
3
|
7
|
gnutls_srp.c
|
|
_gnutls_ext_deinit
|
1
|
3
|
7
|
gnutls_extensions.c
|
|
wrap_nettle_cipher_auth
|
1
|
3
|
9
|
nettle/cipher.c
|
|
_gnutls_buffer_delete_data
|
1
|
3
|
10
|
gnutls_str.c
|
|
wrap_padlock_hash_reset
|
1
|
3
|
8
|
accelerated/x86/sha-padlock.c
|
|
wrap_nettle_cipher_encrypt
|
1
|
3
|
11
|
nettle/cipher.c
|
|
wrap_nettle_cipher_decrypt
|
1
|
3
|
11
|
nettle/cipher.c
|
|
calc_subpktsize
|
1
|
3
|
9
|
opencdk/write-packet.c
|
|
_gnutls_handshake_internal_state_clear
|
1
|
3
|
9
|
gnutls_state.c
|
|
wrap_nettle_hash_update
|
1
|
3
|
9
|
nettle/mac.c
|
|
wrap_padlock_hmac_update
|
1
|
3
|
9
|
accelerated/x86/hmac-padlock.c
|
|
_gnutls_kx_needs_dh_params
|
1
|
3
|
7
|
algorithms/kx.c
|
|
_gnutls_kx_needs_rsa_params
|
1
|
3
|
7
|
algorithms/kx.c
|
|
wrap_nettle_hmac_update
|
1
|
3
|
9
|
nettle/mac.c
|
|
_gnutls_sign_get_pk_algorithm
|
1
|
3
|
9
|
algorithms/sign.c
|
|
gnutls_pubkey_import_privkey
|
1
|
3
|
10
|
gnutls_pubkey.c
|
|
gnutls_system_mutex_deinit
|
1
|
3
|
7
|
system.c
|
|
_gnutls_sign_get_hash_algorithm
|
1
|
3
|
9
|
algorithms/sign.c
|
|
_gnutls_version_get_major
|
1
|
3
|
8
|
algorithms/protocols.c
|
|
gnutls_certificate_type_set_priority
|
1
|
3
|
13
|
gnutls_priority.c
|
|
_gnutls_max_record_pack
|
1
|
3
|
10
|
ext/max_record.c
|
|
gnutls_cipher_get_name
|
1
|
3
|
10
|
algorithms/ciphers.c
|
|
_gnutls_version_get_minor
|
1
|
3
|
8
|
algorithms/protocols.c
|
|
_gnutls_cipher_get_export_flag
|
1
|
3
|
8
|
algorithms/ciphers.c
|
|
_gnutls_compression_get_id
|
1
|
3
|
10
|
gnutls_compress.c
|
|
_gnutls_x509_mac_to_oid
|
1
|
3
|
10
|
algorithms/mac.c
|
|
_gnutls_cipher_get_iv_size
|
1
|
3
|
8
|
algorithms/ciphers.c
|
|
gnutls_system_mutex_deinit
|
1
|
3
|
8
|
system.c
|
|
gnutls_kx_get_name
|
1
|
3
|
10
|
algorithms/kx.c
|
|
get_comp_level
|
1
|
3
|
8
|
gnutls_compress.c
|
|
gnutls_cipher_get_key_size
|
1
|
3
|
8
|
algorithms/ciphers.c
|
|
cryptodev_deinit
|
1
|
3
|
8
|
accelerated/cryptodev.c
|
|
get_mem_level
|
1
|
3
|
8
|
gnutls_compress.c
|
|
gnutls_x509_crt_get_ca_status
|
1
|
3
|
8
|
x509/x509.c
|
|
get_wbits
|
1
|
3
|
8
|
gnutls_compress.c
|
|
_gnutls_crypto_deregister
|
1
|
3
|
7
|
crypto-backend.c
|
|
aes_gcm_auth
|
1
|
3
|
9
|
accelerated/x86/aes-gcm-padlock.c
|
|
_gnutls_cipher_algo_is_aead
|
1
|
3
|
9
|
algorithms/ciphers.c
|
|
check_pclmul
|
1
|
3
|
8
|
accelerated/x86/aes-x86.c
|
|
aes_gcm_decrypt
|
1
|
3
|
9
|
accelerated/x86/aes-gcm-padlock.c
|
|
_gnutls_cipher_is_block
|
1
|
3
|
9
|
algorithms/ciphers.c
|
|
_gnutls_kx_auth_struct
|
1
|
3
|
8
|
algorithms/kx.c
|
|
gnutls_mac_get_key_size
|
1
|
3
|
10
|
algorithms/mac.c
|
|
_gnutls_compression_get_num
|
1
|
3
|
10
|
gnutls_compress.c
|
|
gnutls_protocol_get_name
|
1
|
3
|
9
|
algorithms/protocols.c
|
|
check_optimized_aes
|
1
|
3
|
8
|
accelerated/x86/aes-x86.c
|
|
_gnutls_session_is_ecc
|
1
|
3
|
14
|
gnutls_state.c
|
|
aes_gcm_encrypt
|
1
|
3
|
10
|
accelerated/x86/aes-gcm-padlock.c
|
|
stream_flush
|
1
|
3
|
10
|
opencdk/stream.c
|
|
cryptodev_setiv
|
1
|
3
|
9
|
accelerated/cryptodev.c
|
|
gnutls_cipher_get_block_size
|
1
|
3
|
8
|
algorithms/ciphers.c
|
|
_gnutls_buffer_replace_data
|
1
|
3
|
6
|
gnutls_str.c
|
|
gnutls_prf_raw
|
1
|
3
|
16
|
gnutls_state.c
|
|
gnutls_pubkey_set_key_usage
|
1
|
2
|
7
|
gnutls_pubkey.c
|
|
gnutls_anon_allocate_client_credentials
|
1
|
2
|
11
|
gnutls_anon_cred.c
|
|
gnutls_x509_crt_verify
|
1
|
2
|
14
|
x509/verify.c
|
|
gnutls_transport_set_ptr
|
1
|
2
|
7
|
gnutls_record.c
|
|
gnutls_sign_callback_set
|
1
|
2
|
7
|
gnutls_cert.c
|
|
gnutls_pkcs11_privkey_deinit
|
1
|
2
|
6
|
pkcs11_privkey.c
|
|
_gnutls_record_set_default_version
|
1
|
2
|
7
|
gnutls_state.c
|
|
_gnutls_map_pk_get_pk
|
1
|
2
|
7
|
algorithms/publickey.c
|
|
gnutls_certificate_set_verify_limits
|
1
|
2
|
8
|
gnutls_ui.c
|
|
_gnutls_session_ecc_curve_set
|
1
|
2
|
7
|
gnutls_state.c
|
|
gnutls_pkcs11_set_token_function
|
1
|
2
|
7
|
pkcs11.c
|
|
gnutls_pkcs11_set_pin_function
|
1
|
2
|
7
|
pkcs11.c
|
|
_gnutls_handshake_buffer_clear
|
1
|
2
|
5
|
gnutls_buffers.h
|
|
gnutls_anon_allocate_server_credentials
|
1
|
2
|
9
|
gnutls_anon_cred.c
|
|
_gnutls_session_cert_type_set
|
1
|
2
|
8
|
gnutls_state.c
|
|
_mbuffer_set_udata
|
1
|
2
|
6
|
gnutls_mbuffers.h
|
|
gnutls_hash_deinit
|
1
|
2
|
6
|
crypto-api.c
|
|
_gnutls_buffer_reset
|
1
|
2
|
5
|
gnutls_str.h
|
|
gnutls_dtls_set_timeouts
|
1
|
2
|
6
|
gnutls_dtls.c
|
|
_gnutls_log
|
1
|
2
|
62
|
gnutls_errors.h
|
|
wrap_nettle_cipher_tag
|
1
|
2
|
8
|
nettle/cipher.c
|
|
gnutls_hmac_deinit
|
1
|
2
|
6
|
crypto-api.c
|
|
rot_window
|
1
|
2
|
5
|
gnutls_dtls.c
|
|
_gnutls_x509_read_dsa_pubkey
|
1
|
2
|
7
|
x509/key_decode.c
|
|
_gnutls_kx_encipher_type
|
1
|
2
|
7
|
algorithms/publickey.c
|
|
wrap_padlock_hmac_reset
|
1
|
2
|
7
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_cipher_decrypt2
|
1
|
2
|
9
|
crypto-api.c
|
|
_gnutls_free_rsa_info
|
1
|
2
|
6
|
auth/cert.c
|
|
wrap_nettle_hmac_reset
|
1
|
2
|
7
|
nettle/mac.c
|
|
gnutls_cipher_encrypt2
|
1
|
2
|
9
|
crypto-api.c
|
|
_gnutls_conv_uint16
|
1
|
2
|
9
|
gnutls_num.c
|
|
wrap_nettle_mpi_release
|
1
|
2
|
6
|
nettle/mpi.c
|
|
_gnutls_conv_uint32
|
1
|
2
|
9
|
gnutls_num.c
|
|
_gnutls_write_uint16
|
1
|
2
|
9
|
gnutls_num.c
|
|
check_phe_sha512
|
1
|
2
|
7
|
accelerated/x86/aes-padlock.c
|
|
gnutls_system_mutex_unlock
|
1
|
2
|
6
|
system.c
|
|
check_phe
|
1
|
2
|
7
|
accelerated/x86/aes-padlock.c
|
|
gnutls_system_mutex_lock
|
1
|
2
|
6
|
system.c
|
|
pkcs11_rescan_slots
|
1
|
2
|
8
|
pkcs11.c
|
|
check_padlock
|
1
|
2
|
7
|
accelerated/x86/aes-padlock.c
|
|
_gnutls_write_uint32
|
1
|
2
|
9
|
gnutls_num.c
|
|
gnutls_cipher_encrypt
|
1
|
2
|
7
|
crypto-api.c
|
|
wrap_nettle_mpi_cmp_ui
|
1
|
2
|
7
|
nettle/mpi.c
|
|
wrap_nettle_mpi_cmp
|
1
|
2
|
7
|
nettle/mpi.c
|
|
gnutls_psk_free_server_credentials
|
1
|
2
|
6
|
gnutls_psk.c
|
|
gnutls_compression_set_priority
|
1
|
2
|
6
|
gnutls_priority.c
|
|
gnutls_transport_set_vec_push_function
|
1
|
2
|
7
|
system_override.c
|
|
aes_gcm_tag
|
1
|
2
|
7
|
accelerated/x86/aes-gcm-padlock.c
|
|
gnutls_transport_get_ptr2
|
1
|
2
|
9
|
gnutls_record.c
|
|
_gnutls_write_uint64
|
1
|
2
|
8
|
gnutls_num.c
|
|
gnutls_mac_set_priority
|
1
|
2
|
6
|
gnutls_priority.c
|
|
gnutls_transport_set_push_function
|
1
|
2
|
7
|
system_override.c
|
|
_gnutls_rsa_pms_set_version
|
1
|
2
|
7
|
gnutls_state.c
|
|
_gnutls_priority_prefer_aes_gcm
|
1
|
2
|
5
|
gnutls_priority.c
|
|
gnutls_kx_set_priority
|
1
|
2
|
6
|
gnutls_priority.c
|
|
gnutls_transport_set_ptr2
|
1
|
2
|
8
|
gnutls_record.c
|
|
_gnutls_handshake_hash_buffers_clear
|
1
|
2
|
6
|
gnutls_handshake.c
|
|
_ecc_params_to_privkey
|
1
|
11
|
16
|
nettle/pk.c
|
|
aes_gcm_tag
|
1
|
11
|
20
|
accelerated/x86/aes-gcm-x86.c
|
|
resume_copy_required_values
|
1
|
11
|
45
|
gnutls_handshake.c
|
|
_gnutls_handshake_internal_state_init
|
1
|
10
|
22
|
gnutls_state.c
|
|
gnutls_x509_crq_print
|
1
|
10
|
24
|
x509/output.c
|
|
_ecc_params_to_pubkey
|
1
|
10
|
15
|
nettle/pk.c
|
|
gnutls_priority_deinit
|
1
|
1
|
5
|
gnutls_priority.c
|
|
_gnutls_x509_read_ecc_pubkey
|
1
|
1
|
9
|
x509/key_decode.c
|
|
_mbuffer_get_uhead_size
|
1
|
1
|
5
|
gnutls_mbuffers.h
|
|
_gcm_decrypt
|
1
|
1
|
7
|
nettle/cipher.c
|
|
padlock_hmac_sha256_set_key
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_x509_crl_check_issuer
|
1
|
1
|
6
|
x509/verify.c
|
|
gnutls_x509_crt_set_crl_dist_points
|
1
|
1
|
10
|
x509/x509_write.c
|
|
system_writev
|
1
|
1
|
8
|
system.c
|
|
gnutls_certificate_free_cas
|
1
|
1
|
6
|
gnutls_cert.c
|
|
gnutls_record_check_pending
|
1
|
1
|
5
|
gnutls_buffers.c
|
|
_gnutls_set_current_version
|
1
|
1
|
6
|
gnutls_int.h
|
|
padlock_sha512_update
|
1
|
1
|
6
|
accelerated/x86/sha-padlock.c
|
|
_gnutls_protocol_get_version
|
1
|
1
|
5
|
gnutls_int.h
|
|
gnutls_dh_set_prime_bits
|
1
|
1
|
5
|
gnutls_ui.c
|
|
padlock_hmac_sha1_digest
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
_clear_priorities
|
1
|
1
|
5
|
gnutls_priority.c
|
|
_gcm_encrypt
|
1
|
1
|
7
|
nettle/cipher.c
|
|
gnutls_certificate_type_list
|
1
|
1
|
5
|
algorithms/cert_types.c
|
|
gnutls_db_set_store_function
|
1
|
1
|
6
|
gnutls_db.c
|
|
gnutls_global_set_audit_log_function
|
1
|
1
|
5
|
gnutls_global.c
|
|
_gnutls_x509_export_int
|
1
|
1
|
11
|
x509/common.c
|
|
padlock_sha256_update
|
1
|
1
|
6
|
accelerated/x86/sha-padlock.c
|
|
padlock_hmac_sha1_update
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_x509_crt_sign
|
1
|
1
|
6
|
x509/x509_write.c
|
|
gnutls_transport_set_pull_function
|
1
|
1
|
6
|
system_override.c
|
|
gnutls_handshake_set_private_extensions
|
1
|
1
|
5
|
gnutls_state.c
|
|
_mbuffer_get_udata_size
|
1
|
1
|
5
|
gnutls_mbuffers.h
|
|
padlock_sha1_update
|
1
|
1
|
6
|
accelerated/x86/sha-padlock.c
|
|
system_write
|
1
|
1
|
5
|
system.c
|
|
padlock_hmac_sha1_set_key
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_srp_set_prime_bits
|
1
|
1
|
5
|
gnutls_srp.c
|
|
_gnutls_openpgp_send_fingerprint
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_certificate_send_x509_rdn_sequence
|
1
|
1
|
6
|
gnutls_state.c
|
|
gnutls_anon_set_params_function
|
1
|
1
|
6
|
gnutls_ui.c
|
|
gnutls_record_get_discarded
|
1
|
1
|
4
|
gnutls_dtls.c
|
|
gnutls_record_disable_padding
|
1
|
1
|
5
|
gnutls_record.c
|
|
gnutls_privkey_get_type
|
1
|
1
|
5
|
gnutls_privkey.c
|
|
_mbuffer_set_udata_size
|
1
|
1
|
5
|
gnutls_mbuffers.h
|
|
gnutls_psk_set_params_function
|
1
|
1
|
6
|
gnutls_ui.c
|
|
gnutls_openpgp_send_cert
|
1
|
1
|
6
|
gnutls_state.c
|
|
gnutls_rnd
|
1
|
1
|
5
|
random.c
|
|
aes_gcm_deinit
|
1
|
1
|
5
|
accelerated/x86/aes-gcm-x86.c
|
|
aes_gcm_deinit
|
1
|
1
|
5
|
accelerated/x86/aes-gcm-padlock.c
|
|
gnutls_certificate_set_rsa_export_params
|
1
|
1
|
6
|
gnutls_ui.c
|
|
gnutls_openpgp_set_recv_key_function
|
1
|
1
|
6
|
openpgp/gnutls_openpgp.c
|
|
gnutls_db_set_remove_function
|
1
|
1
|
6
|
gnutls_db.c
|
|
wrap_padlock_hash_deinit
|
1
|
1
|
5
|
accelerated/x86/sha-padlock.c
|
|
gnutls_certificate_set_verify_flags
|
1
|
1
|
6
|
gnutls_ui.c
|
|
_mbuffer_get_udata_ptr
|
1
|
1
|
5
|
gnutls_mbuffers.h
|
|
cdk_stream_open
|
1
|
1
|
5
|
opencdk/stream.c
|
|
gnutls_global_set_log_function
|
1
|
1
|
5
|
gnutls_global.c
|
|
gnutls_rsa_params_import_raw
|
1
|
1
|
11
|
gnutls_rsa_export.c
|
|
gnutls_certificate_set_params_function
|
1
|
1
|
6
|
gnutls_ui.c
|
|
_dsa_params_to_privkey
|
1
|
1
|
6
|
nettle/pk.c
|
|
gnutls_srp_set_client_credentials_function
|
1
|
1
|
8
|
gnutls_srp.c
|
|
gnutls_certificate_set_dh_params
|
1
|
1
|
6
|
gnutls_ui.c
|
|
_gnutls_null_log
|
1
|
1
|
5
|
gnutls_errors.c
|
|
_gnutls_cipher_setiv
|
1
|
1
|
5
|
gnutls_cipher_int.h
|
|
_mbuffer_get_uhead_ptr
|
1
|
1
|
5
|
gnutls_mbuffers.h
|
|
gnutls_srp_set_server_credentials_function
|
1
|
1
|
8
|
gnutls_srp.c
|
|
gnutls_transport_set_errno
|
1
|
1
|
5
|
system_override.c
|
|
gnutls_x509_privkey_import_rsa_raw
|
1
|
1
|
12
|
x509/privkey.c
|
|
gnutls_certificate_client_get_request_status
|
1
|
1
|
5
|
gnutls_ui.c
|
|
cdk_subpkt_find
|
1
|
1
|
5
|
opencdk/new-packet.c
|
|
gnutls_x509_crt_check_issuer
|
1
|
1
|
6
|
x509/verify.c
|
|
stream_encrypt
|
1
|
1
|
7
|
nettle/cipher.c
|
|
gnutls_hash_fast
|
1
|
1
|
6
|
crypto-api.c
|
|
_gnutls_x509_crl_set_extension
|
1
|
1
|
9
|
x509/extensions.c
|
|
_gnutls_x509_crt_set_extension
|
1
|
1
|
9
|
x509/extensions.c
|
|
gnutls_certificate_set_verify_function
|
1
|
1
|
7
|
gnutls_cert.c
|
|
gnutls_x509_crt_set_ca_status
|
1
|
1
|
5
|
x509/x509_write.c
|
|
gnutls_db_set_retrieve_function
|
1
|
1
|
6
|
gnutls_db.c
|
|
gnutls_hash_get_len
|
1
|
1
|
5
|
crypto-api.c
|
|
_gnutls_dh_get_allowed_prime_bits
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_dtls_get_mtu
|
1
|
1
|
4
|
gnutls_dtls.c
|
|
rnd_func
|
1
|
1
|
5
|
nettle/pk.c
|
|
gnutls_x509_crt_get_signature_algorithm
|
1
|
1
|
5
|
x509/x509.c
|
|
gnutls_hex2bin
|
1
|
1
|
6
|
gnutls_str.c
|
|
gnutls_session_ticket_key_generate
|
1
|
1
|
5
|
ext/session_ticket.c
|
|
gnutls_pk_params_init
|
1
|
1
|
5
|
gnutls_pk.c
|
|
gnutls_certificate_set_retrieve_function2
|
1
|
1
|
6
|
gnutls_cert.c
|
|
gnutls_hash_output
|
1
|
1
|
5
|
crypto-api.c
|
|
gnutls_psk_set_server_params_function
|
1
|
1
|
6
|
gnutls_psk.c
|
|
_cdk_armor_get_lineend
|
1
|
1
|
5
|
opencdk/armor.c
|
|
gnutls_dtls_set_mtu
|
1
|
1
|
4
|
gnutls_dtls.c
|
|
gnutls_hash
|
1
|
1
|
5
|
crypto-api.c
|
|
gnutls_psk_set_server_dh_params
|
1
|
1
|
6
|
gnutls_psk.c
|
|
_gnutls_sr_deinit_data
|
1
|
1
|
5
|
ext/safe_renegotiation.c
|
|
_gnutls_cryptodev_deinit
|
1
|
1
|
5
|
accelerated/cryptodev.c
|
|
_gnutls_cryptodev_init
|
1
|
1
|
5
|
accelerated/cryptodev.c
|
|
gnutls_anon_free_server_credentials
|
1
|
1
|
6
|
gnutls_anon_cred.c
|
|
gnutls_certificate_set_retrieve_function
|
1
|
1
|
6
|
gnutls_cert.c
|
|
register_mac
|
1
|
1
|
5
|
accelerated/cryptodev.c
|
|
_gnutls_server_name_deinit_data
|
1
|
1
|
5
|
ext/server_name.c
|
|
_gnutls_session_is_resumable
|
1
|
1
|
5
|
gnutls_state.c
|
|
_gnutls_str_array_init
|
1
|
1
|
4
|
gnutls_str_array.h
|
|
gnutls_hmac_fast
|
1
|
1
|
7
|
crypto-api.c
|
|
gnutls_perror
|
1
|
1
|
5
|
gnutls_errors.c
|
|
gnutls_certificate_server_set_retrieve_function
|
1
|
1
|
6
|
gnutls_cert.c
|
|
gnutls_hmac_get_len
|
1
|
1
|
5
|
crypto-api.c
|
|
wrap_nettle_cipher_close
|
1
|
1
|
5
|
nettle/cipher.c
|
|
ecc_free
|
1
|
1
|
6
|
nettle/ecc_free.c
|
|
gnutls_certificate_client_set_retrieve_function
|
1
|
1
|
6
|
gnutls_cert.c
|
|
gnutls_alert_get
|
1
|
1
|
5
|
gnutls_alert.c
|
|
gnutls_hmac_output
|
1
|
1
|
5
|
crypto-api.c
|
|
signature_algorithms_deinit_data
|
1
|
1
|
5
|
ext/signature.c
|
|
_gnutls_calc_srp_x
|
1
|
1
|
8
|
gnutls_srp.c
|
|
gnutls_handshake_get_last_out
|
1
|
1
|
5
|
gnutls_handshake.c
|
|
gnutls_handshake_get_last_in
|
1
|
1
|
5
|
gnutls_handshake.c
|
|
_gnutls_get_adv_version
|
1
|
1
|
6
|
gnutls_handshake.c
|
|
_gnutls_set_adv_version
|
1
|
1
|
6
|
gnutls_handshake.c
|
|
gnutls_handshake_set_max_packet_length
|
1
|
1
|
5
|
gnutls_handshake.c
|
|
gnutls_hmac
|
1
|
1
|
5
|
crypto-api.c
|
|
gnutls_pkcs11_obj_get_info
|
1
|
1
|
7
|
pkcs11.c
|
|
gnutls_crypto_init
|
1
|
1
|
5
|
nettle/init.c
|
|
_gnutls_record_buffer_get_size
|
1
|
1
|
5
|
gnutls_buffers.h
|
|
_gnutls_session_ecc_curve_get
|
1
|
1
|
4
|
gnutls_state.h
|
|
gnutls_certificate_server_set_request
|
1
|
1
|
6
|
gnutls_cert.c
|
|
gnutls_psk_set_client_credentials_function
|
1
|
1
|
8
|
gnutls_psk.c
|
|
pkcs11_strerror
|
1
|
1
|
5
|
pkcs11.c
|
|
pkcs11_set_pin
|
1
|
1
|
10
|
pkcs11.c
|
|
pkcs11_init_pin
|
1
|
1
|
8
|
pkcs11.c
|
|
pkcs11_init_token
|
1
|
1
|
7
|
pkcs11.c
|
|
pkcs11_destroy_object
|
1
|
1
|
7
|
pkcs11.c
|
|
rsa_unblind
|
1
|
1
|
5
|
nettle/pk.c
|
|
pkcs11_create_object
|
1
|
1
|
9
|
pkcs11.c
|
|
pkcs11_decrypt
|
1
|
1
|
10
|
pkcs11.c
|
|
wrap_nettle_hash_deinit
|
1
|
1
|
5
|
nettle/mac.c
|
|
pkcs11_decrypt_init
|
1
|
1
|
8
|
pkcs11.c
|
|
_gnutls_x509_crl_get_extension_oid
|
1
|
1
|
7
|
x509/extensions.c
|
|
pkcs11_generate_key_pair
|
1
|
1
|
14
|
pkcs11.c
|
|
pkcs11_sign
|
1
|
1
|
10
|
pkcs11.c
|
|
pkcs11_sign_init
|
1
|
1
|
8
|
pkcs11.c
|
|
pkcs11_get_mechanism_list
|
1
|
1
|
8
|
pkcs11.c
|
|
pkcs11_get_attribute_value
|
1
|
1
|
9
|
pkcs11.c
|
|
wrap_padlock_hmac_deinit
|
1
|
1
|
5
|
accelerated/x86/hmac-padlock.c
|
|
pkcs11_close_session
|
1
|
1
|
6
|
pkcs11.c
|
|
pkcs11_find_objects_final
|
1
|
1
|
6
|
pkcs11.c
|
|
_gnutls_get_auth_info
|
1
|
1
|
5
|
gnutls_auth.c
|
|
pkcs11_find_objects
|
1
|
1
|
9
|
pkcs11.c
|
|
gnutls_certificate_set_openpgp_key_file
|
1
|
1
|
9
|
openpgp/gnutls_openpgp.c
|
|
pkcs11_find_objects_init
|
1
|
1
|
8
|
pkcs11.c
|
|
_gnutls_x509_crt_get_extension_oid
|
1
|
1
|
7
|
x509/extensions.c
|
|
pkcs11_get_token_info
|
1
|
1
|
7
|
pkcs11.c
|
|
pkcs11_get_slot_info
|
1
|
1
|
7
|
pkcs11.c
|
|
_gnutls_get_crypto_digest
|
1
|
1
|
5
|
crypto-backend.c
|
|
pkcs11_get_module_info
|
1
|
1
|
6
|
pkcs11.c
|
|
pkcs11_get_slot_list
|
1
|
1
|
6
|
pkcs11.c
|
|
gnutls_record_get_max_size
|
1
|
1
|
8
|
ext/max_record.c
|
|
gnutls_psk_set_server_credentials_function
|
1
|
1
|
8
|
gnutls_psk.c
|
|
gnutls_crypto_single_digest_register
|
1
|
1
|
7
|
crypto-backend.c
|
|
cdk_stream_tmp_new
|
1
|
1
|
5
|
opencdk/stream.c
|
|
gnutls_system_mutex_unlock
|
1
|
1
|
5
|
system.c
|
|
_gnutls_cryptodev_deinit
|
1
|
1
|
5
|
accelerated/cryptodev.c
|
|
gnutls_system_mutex_lock
|
1
|
1
|
5
|
system.c
|
|
gnutls_certificate_set_openpgp_key_mem
|
1
|
1
|
9
|
openpgp/gnutls_openpgp.c
|
|
gnutls_x509_crt_import_pkcs11
|
1
|
1
|
6
|
pkcs11.c
|
|
gnutls_system_mutex_deinit
|
1
|
1
|
5
|
system.c
|
|
wrap_nettle_hmac_deinit
|
1
|
1
|
5
|
nettle/mac.c
|
|
gnutls_system_mutex_init
|
1
|
1
|
5
|
system.c
|
|
session_unresumable
|
1
|
1
|
5
|
gnutls_record.c
|
|
_gnutls_get_crypto_mac
|
1
|
1
|
5
|
crypto-backend.c
|
|
_cdk_keydb_is_secret
|
1
|
1
|
5
|
opencdk/keydb.c
|
|
session_invalidate
|
1
|
1
|
5
|
gnutls_record.c
|
|
gnutls_x509_crt_check_revocation
|
1
|
1
|
7
|
x509/x509.c
|
|
cdk_s2k_free
|
1
|
1
|
5
|
opencdk/seskey.c
|
|
gnutls_crypto_single_mac_register
|
1
|
1
|
7
|
crypto-backend.c
|
|
gnutls_certificate_free_crls
|
1
|
1
|
6
|
gnutls_x509.c
|
|
gnutls_openpgp_privkey_export
|
1
|
1
|
10
|
openpgp/privkey.c
|
|
gnutls_auth_client_get_type
|
1
|
1
|
8
|
gnutls_auth.c
|
|
_cdk_tmpfile
|
1
|
1
|
5
|
opencdk/misc.c
|
|
_gnutls_buffer_append_str
|
1
|
1
|
5
|
gnutls_str.c
|
|
_gnutls_digest_get_name
|
1
|
1
|
5
|
algorithms/mac.c
|
|
_gnutls_x509_oid2digest_algorithm
|
1
|
1
|
5
|
algorithms/mac.c
|
|
gnutls_openpgp_crt_export
|
1
|
1
|
8
|
openpgp/pgp.c
|
|
wrap_nettle_mpi_get_nbits
|
1
|
1
|
5
|
nettle/mpi.c
|
|
gnutls_x509_crt_get_issuer
|
1
|
1
|
5
|
x509/x509.c
|
|
_gnutls_x509_digest_to_oid
|
1
|
1
|
5
|
algorithms/mac.c
|
|
gnutls_x509_crt_get_subject
|
1
|
1
|
5
|
x509/x509.c
|
|
gnutls_auth_server_get_type
|
1
|
1
|
8
|
gnutls_auth.c
|
|
gnutls_x509_crt_get_raw_dn
|
1
|
1
|
5
|
x509/x509.c
|
|
gnutls_x509_crt_get_raw_issuer_dn
|
1
|
1
|
6
|
x509/x509.c
|
|
gnutls_rsa_params_export_pkcs1
|
1
|
1
|
9
|
gnutls_rsa_export.c
|
|
_gnutls_auth_cipher_is_aead
|
1
|
1
|
4
|
gnutls_cipher_int.h
|
|
_gnutls_get_crypto_cipher
|
1
|
1
|
5
|
crypto-backend.c
|
|
gnutls_pkcs11_obj_get_type
|
1
|
1
|
5
|
pkcs11.c
|
|
_gnutls_x509_crl_get_extension
|
1
|
1
|
8
|
x509/extensions.c
|
|
_gnutls_auth_cipher_tag_len
|
1
|
1
|
4
|
gnutls_cipher_int.h
|
|
gnutls_x509_crq_get_subject_alt_othername_oid
|
1
|
1
|
7
|
x509/crq.c
|
|
gnutls_transport_set_errno_function
|
1
|
1
|
6
|
system_override.c
|
|
gnutls_x509_crq_get_subject_alt_name
|
1
|
1
|
10
|
x509/crq.c
|
|
gnutls_certificate_set_x509_crl_mem
|
1
|
1
|
7
|
gnutls_x509.c
|
|
_gnutls_set_client_random
|
1
|
1
|
6
|
gnutls_handshake.c
|
|
_gnutls_auth_cipher_setiv
|
1
|
1
|
5
|
gnutls_cipher_int.h
|
|
gnutls_crypto_single_cipher_register
|
1
|
1
|
7
|
crypto-backend.c
|
|
_gnutls_x509_crq_get_mpis
|
1
|
1
|
10
|
x509/mpi.c
|
|
_gnutls_x509_crt_get_extension
|
1
|
1
|
8
|
x509/extensions.c
|
|
gnutls_rsa_params_import_pkcs1
|
1
|
1
|
7
|
gnutls_rsa_export.c
|
|
_gnutls_set_server_random
|
1
|
1
|
6
|
gnutls_handshake.c
|
|
padlock_hmac_sha512_digest
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
_cdk_stream_puts
|
1
|
1
|
5
|
opencdk/stream.c
|
|
aes_deinit
|
1
|
1
|
5
|
accelerated/x86/aes-padlock.c
|
|
_gnutls_x509_crt_get_mpis
|
1
|
1
|
9
|
x509/mpi.c
|
|
gnutls_x509_crl_sign
|
1
|
1
|
6
|
x509/crl_write.c
|
|
_gnutls_pubkey_get_mpis
|
1
|
1
|
6
|
gnutls_pubkey.c
|
|
padlock_hmac_sha512_update
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
padlock_hmac_sha512_set_key
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_rsa_params_generate2
|
1
|
1
|
5
|
gnutls_rsa_export.c
|
|
gnutls_protocol_get_version
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_ecc_curve_get
|
1
|
1
|
4
|
gnutls_state.c
|
|
gnutls_x509_crt_get_issuer_alt_othername_oid
|
1
|
1
|
7
|
x509/x509.c
|
|
padlock_hmac_sha384_digest
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_x509_crt_get_subject_alt_othername_oid
|
1
|
1
|
7
|
x509/x509.c
|
|
gnutls_certificate_free_ca_names
|
1
|
1
|
5
|
gnutls_cert.c
|
|
gnutls_session_enable_compatibility_mode
|
1
|
1
|
5
|
gnutls_state.c
|
|
padlock_hmac_sha384_set_key
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
reset_errno
|
1
|
1
|
5
|
gnutls_buffers.c
|
|
gnutls_x509_crt_get_issuer_alt_name2
|
1
|
1
|
10
|
x509/x509.c
|
|
gnutls_anon_set_server_params_function
|
1
|
1
|
6
|
gnutls_anon_cred.c
|
|
gnutls_handshake_set_post_client_hello_function
|
1
|
1
|
7
|
gnutls_state.c
|
|
gnutls_db_set_cache_expiration
|
1
|
1
|
5
|
gnutls_db.c
|
|
gnutls_x509_crt_get_subject_alt_name2
|
1
|
1
|
10
|
x509/x509.c
|
|
_gnutls_gen_ecdh_common_client_kx
|
1
|
1
|
6
|
auth/ecdh_common.c
|
|
gnutls_transport_get_ptr
|
1
|
1
|
5
|
gnutls_record.c
|
|
gnutls_record_get_direction
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_record_recv_seq
|
1
|
1
|
7
|
gnutls_record.c
|
|
padlock_hmac_sha224_digest
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_x509_crt_get_issuer_alt_name
|
1
|
1
|
9
|
x509/x509.c
|
|
gnutls_session_set_ptr
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_rsa_params_cpy
|
1
|
1
|
5
|
gnutls_rsa_export.c
|
|
_gnutls_hash_get_algo_len
|
1
|
1
|
5
|
gnutls_hash_int.c
|
|
gnutls_record_recv
|
1
|
1
|
6
|
gnutls_record.c
|
|
gnutls_session_get_ptr
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_kx_get
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_compression_list
|
1
|
1
|
5
|
gnutls_compress.c
|
|
gnutls_x509_crt_get_subject_alt_name
|
1
|
1
|
9
|
x509/x509.c
|
|
_gnutls_gen_dh_common_client_kx
|
1
|
1
|
4
|
auth/dh_common.c
|
|
gnutls_record_send
|
1
|
1
|
8
|
gnutls_record.c
|
|
gnutls_global_set_log_level
|
1
|
1
|
5
|
gnutls_global.c
|
|
gnutls_pkcs11_privkey_get_info
|
1
|
1
|
7
|
pkcs11_privkey.c
|
|
padlock_hmac_sha224_set_key
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
gnutls_db_get_ptr
|
1
|
1
|
5
|
gnutls_db.c
|
|
gnutls_anon_set_server_dh_params
|
1
|
1
|
6
|
gnutls_anon_cred.c
|
|
gnutls_certificate_get_issuer
|
1
|
1
|
6
|
gnutls_cert.c
|
|
gnutls_set_default_export_priority
|
1
|
1
|
5
|
gnutls_priority.c
|
|
padlock_hmac_sha256_digest
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
aes_deinit
|
1
|
1
|
5
|
accelerated/x86/aes-x86.c
|
|
gnutls_set_default_priority
|
1
|
1
|
5
|
gnutls_priority.c
|
|
_gnutls_cipher_is_aead
|
1
|
1
|
4
|
gnutls_cipher_int.h
|
|
system_read_peek
|
1
|
1
|
5
|
system.c
|
|
gnutls_x509_privkey_export_rsa_raw
|
1
|
1
|
10
|
x509/privkey.c
|
|
gnutls_x509_crq_sign
|
1
|
1
|
5
|
x509/crq.c
|
|
gnutls_rsa_params_deinit
|
1
|
1
|
5
|
gnutls_rsa_export.c
|
|
gnutls_certificate_type_get
|
1
|
1
|
5
|
gnutls_state.c
|
|
gnutls_transport_set_pull_timeout_function
|
1
|
1
|
6
|
system_override.c
|
|
_gnutls_cipher_tag_len
|
1
|
1
|
4
|
gnutls_cipher_int.h
|
|
padlock_hmac_sha256_update
|
1
|
1
|
6
|
accelerated/x86/hmac-padlock.c
|
|
_mbuffer_set_uhead_size
|
1
|
1
|
5
|
gnutls_mbuffers.h
|
|
system_read
|
1
|
1
|
5
|
system.c
|
|
gnutls_global_set_time_function
|
1
|
1
|
5
|
gnutls_global.c
|
|
_ecc_params_clear
|
1
|
1
|
4
|
nettle/pk.c
|
|
gnutls_x509_dn_deinit
|
1
|
1
|
5
|
x509/dn.c
|
|
gnutls_db_set_ptr
|
1
|
1
|
5
|
gnutls_db.c
|
|
gnutls_anon_free_client_credentials
|
1
|
0
|
4
|
gnutls_anon_cred.c
|
|
gnutls::noncopyable::~noncopyable
|
1
|
0
|
3
|
includes/gnutls/gnutlsxx.h
|
|
gnutls::noncopyable::noncopyable
|
1
|
0
|
3
|
includes/gnutls/gnutlsxx.h
|
|
gnutls::credentials::~credentials
|
1
|
0
|
3
|
includes/gnutls/gnutlsxx.h
|
|
gnutls_free
|
1
|
0
|
4
|
gnutls_mem.c
|
|
gnutls_malloc
|
1
|
0
|
4
|
gnutls_mem.c
|