Browse Source

TT#97302 respond with the same DTLS hash func as was offered

Change-Id: Id72df1083b5d329fa33875853981ec471440a6c1
pull/1093/head
Richard Fuchs 5 years ago
parent
commit
dc4775d5ce
5 changed files with 26 additions and 7 deletions
  1. +8
    -2
      daemon/dtls.c
  2. +14
    -2
      daemon/sdp.c
  3. +1
    -1
      include/dtls.h
  4. +1
    -0
      perl/NGCP/Rtpengine/AutoTest.pm
  5. +2
    -2
      t/auto-daemon-tests.pl

+ 8
- 2
daemon/dtls.c View File

@ -125,6 +125,7 @@ static void cert_free(void *p) {
EVP_PKEY_free(cert->pkey);
if (cert->x509)
X509_free(cert->x509);
g_queue_clear_full(&cert->fingerprints, free);
}
static void buf_dump_free(char *buf, size_t len) {
@ -258,8 +259,13 @@ static int cert_init(void) {
/* digest */
new_cert = obj_alloc0("dtls_cert", sizeof(*new_cert), cert_free);
new_cert->fingerprint.hash_func = &hash_funcs[0];
dtls_fingerprint_hash(&new_cert->fingerprint, x509);
for (int i = 0; i < num_hash_funcs; i++) {
struct dtls_fingerprint *fp = malloc(sizeof(*fp));
fp->hash_func = &hash_funcs[i];
dtls_fingerprint_hash(fp, x509);
g_queue_push_tail(&new_cert->fingerprints, fp);
}
new_cert->x509 = x509;
new_cert->pkey = pkey;


+ 14
- 2
daemon/sdp.c View File

@ -2193,11 +2193,23 @@ static void insert_dtls(struct call_media *media, struct sdp_chopper *chop) {
if (!call->dtls_cert || !MEDIA_ISSET(media, DTLS) || MEDIA_ISSET(media, PASSTHRU))
return;
hf = call->dtls_cert->fingerprint.hash_func;
struct dtls_fingerprint *fp = NULL;
for (GList *l = call->dtls_cert->fingerprints.head; l; l = l->next) {
fp = l->data;
if (!media->fingerprint.hash_func)
break;
if (!strcasecmp(media->fingerprint.hash_func->name, fp->hash_func->name))
break;
fp = NULL;
}
if (!fp) // use first if no match
fp = call->dtls_cert->fingerprints.head->data;
hf = fp->hash_func;
assert(hf->num_bytes > 0);
p = call->dtls_cert->fingerprint.digest;
p = fp->digest;
o = hexbuf;
for (i = 0; i < hf->num_bytes; i++)
o += sprintf(o, "%02X:", *p++);


+ 1
- 1
include/dtls.h View File

@ -41,7 +41,7 @@ struct dtls_fingerprint {
struct dtls_cert {
struct obj obj;
struct dtls_fingerprint fingerprint;
GQueue fingerprints;
EVP_PKEY *pkey;
X509 *x509;
time_t expires;


+ 1
- 0
perl/NGCP/Rtpengine/AutoTest.pm View File

@ -125,6 +125,7 @@ sub offer_answer {
$regexp =~ s/CRYPTO192/([0-9a-zA-Z\/+]{51})/gs;
$regexp =~ s/CRYPTO256/([0-9a-zA-Z\/+]{62})/gs;
$regexp =~ s/LOOPER/([0-9a-f]{12})/gs;
$regexp =~ s/FINGERPRINT256/([0-9a-fA-F:]{95})/gs;
$regexp =~ s/FINGERPRINT/([0-9a-fA-F:]{59})/gs;
my $crlf = crlf($resp->{sdp});
like $crlf, qr/$regexp/s, "$name - output '$cmd' SDP";


+ 2
- 2
t/auto-daemon-tests.pl View File

@ -1872,7 +1872,7 @@ a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
a=setup:active
a=fingerprint:sha-1 FINGERPRINT
a=fingerprint:sha-256 FINGERPRINT256
SDP
@ -1925,7 +1925,7 @@ a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
a=setup:passive
a=fingerprint:sha-1 FINGERPRINT
a=fingerprint:sha-256 FINGERPRINT256
SDP


Loading…
Cancel
Save