Loading crypto/pqueue/pq_compat.h +1 −0 Original line number Diff line number Diff line #error "to be deleted" /* crypto/pqueue/pqueue_compat.h */ /* * DTLS implementation written by Nagendra Modadugu Loading crypto/pqueue/pqueue.c +16 −13 Original line number Diff line number Diff line Loading @@ -68,13 +68,12 @@ typedef struct _pqueue } pqueue_s; pitem * pitem_new(PQ_64BIT priority, void *data) pitem_new(unsigned char *prio64be, void *data) { pitem *item = (pitem *) OPENSSL_malloc(sizeof(pitem)); if (item == NULL) return NULL; pq_64bit_init(&(item->priority)); pq_64bit_assign(&item->priority, &priority); memcpy(item->priority,prio64be,sizeof(item->priority)); item->data = data; item->next = NULL; Loading @@ -87,7 +86,6 @@ pitem_free(pitem *item) { if (item == NULL) return; pq_64bit_free(&(item->priority)); OPENSSL_free(item); } Loading Loading @@ -124,7 +122,10 @@ pqueue_insert(pqueue_s *pq, pitem *item) next != NULL; curr = next, next = next->next) { if (pq_64bit_gt(&(next->priority), &(item->priority))) /* we can compare 64-bit value in big-endian encoding * with memcmp:-) */ int cmp = memcmp(next->priority, item->priority,8); if (cmp > 0) /* next > item */ { item->next = next; Loading @@ -135,8 +136,8 @@ pqueue_insert(pqueue_s *pq, pitem *item) return item; } /* duplicates not allowed */ if (pq_64bit_eq(&(item->priority), &(next->priority))) else if (cmp == 0) /* duplicates not allowed */ return NULL; } Loading Loading @@ -164,7 +165,7 @@ pqueue_pop(pqueue_s *pq) } pitem * pqueue_find(pqueue_s *pq, PQ_64BIT priority) pqueue_find(pqueue_s *pq, unsigned char *prio64be) { pitem *next, *prev = NULL; pitem *found = NULL; Loading @@ -175,7 +176,7 @@ pqueue_find(pqueue_s *pq, PQ_64BIT priority) for ( next = pq->items; next->next != NULL; prev = next, next = next->next) { if ( pq_64bit_eq(&(next->priority), &priority)) if ( memcmp(next->priority, prio64be,8) == 0) { found = next; break; Loading @@ -183,7 +184,7 @@ pqueue_find(pqueue_s *pq, PQ_64BIT priority) } /* check the one last node */ if ( pq_64bit_eq(&(next->priority), &priority)) if ( memcpy(next->priority, prio64be,8) ==0) found = next; if ( ! found) Loading @@ -199,7 +200,6 @@ pqueue_find(pqueue_s *pq, PQ_64BIT priority) return found; } #if PQ_64BIT_IS_INTEGER void pqueue_print(pqueue_s *pq) { Loading @@ -207,11 +207,14 @@ pqueue_print(pqueue_s *pq) while(item != NULL) { printf("item\t%lld\n", item->priority); printf("item\t%02x%02x%02x%02x%02x%02x%02x%02x\n", item->priority[0],item->priority[1], item->priority[2],item->priority[3], item->priority[4],item->priority[5], item->priority[6],item->priority[7]); item = item->next; } } #endif pitem * pqueue_iterator(pqueue_s *pq) Loading crypto/pqueue/pqueue.h +3 −5 Original line number Diff line number Diff line Loading @@ -64,20 +64,18 @@ #include <stdlib.h> #include <string.h> #include <openssl/pq_compat.h> typedef struct _pqueue *pqueue; typedef struct _pitem { PQ_64BIT priority; unsigned char priority[8]; /* 64-bit value in big-endian encoding */ void *data; struct _pitem *next; } pitem; typedef struct _pitem *piterator; pitem *pitem_new(PQ_64BIT priority, void *data); pitem *pitem_new(unsigned char *prio64be, void *data); void pitem_free(pitem *item); pqueue pqueue_new(void); Loading @@ -86,7 +84,7 @@ void pqueue_free(pqueue pq); pitem *pqueue_insert(pqueue pq, pitem *item); pitem *pqueue_peek(pqueue pq); pitem *pqueue_pop(pqueue pq); pitem *pqueue_find(pqueue pq, PQ_64BIT priority); pitem *pqueue_find(pqueue pq, unsigned char *prio64be); pitem *pqueue_iterator(pqueue pq); pitem *pqueue_next(piterator *iter); Loading ssl/d1_both.c +15 −16 Original line number Diff line number Diff line Loading @@ -442,7 +442,7 @@ dtls1_buffer_handshake_fragment(SSL *s, struct hm_header_st* msg_hdr) { hm_fragment *frag = NULL; pitem *item = NULL; PQ_64BIT seq64; unsigned char seq64be[8]; frag = dtls1_hm_fragment_new(msg_hdr->frag_len); if ( frag == NULL) Loading @@ -453,15 +453,14 @@ dtls1_buffer_handshake_fragment(SSL *s, struct hm_header_st* msg_hdr) memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); pq_64bit_init(&seq64); pq_64bit_assign_word(&seq64, msg_hdr->seq); memset(seq64be,0,sizeof(seq64be)); seq64be[6] = (unsigned char)(msg_hdr->seq>>8); seq64be[7] = (unsigned char)(msg_hdr->seq); item = pitem_new(seq64, frag); item = pitem_new(seq64be, frag); if ( item == NULL) goto err; pq_64bit_free(&seq64); pqueue_insert(s->d1->buffered_messages, item); return 1; Loading Loading @@ -1043,7 +1042,7 @@ dtls1_buffer_message(SSL *s, int is_ccs) { pitem *item; hm_fragment *frag; PQ_64BIT seq64; unsigned char seq64be[8]; /* this function is called immediately after a message has * been serialized */ Loading Loading @@ -1071,11 +1070,11 @@ dtls1_buffer_message(SSL *s, int is_ccs) frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; frag->msg_header.is_ccs = is_ccs; pq_64bit_init(&seq64); pq_64bit_assign_word(&seq64, frag->msg_header.seq); memset(seq64be,0,sizeof(seq64be)); seq64be[6] = (unsigned char)(frag->msg_header.seq>>8); seq64be[7] = (unsigned char)(frag->msg_header.seq); item = pitem_new(seq64, frag); pq_64bit_free(&seq64); item = pitem_new(seq64be, frag); if ( item == NULL) { dtls1_hm_fragment_free(frag); Loading @@ -1101,7 +1100,7 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, pitem *item; hm_fragment *frag ; unsigned long header_length; PQ_64BIT seq64; unsigned char seq64be[8]; /* OPENSSL_assert(s->init_num == 0); Loading @@ -1109,11 +1108,11 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, */ /* XDTLS: the requested message ought to be found, otherwise error */ pq_64bit_init(&seq64); pq_64bit_assign_word(&seq64, seq); memset(seq64be,0,sizeof(seq64be)); seq64be[6] = (unsigned char)(seq>>8); seq64be[7] = (unsigned char)seq; item = pqueue_find(s->d1->sent_messages, seq64); pq_64bit_free(&seq64); item = pqueue_find(s->d1->sent_messages, seq64be); if ( item == NULL) { fprintf(stderr, "retransmit: message %d non-existant\n", seq); Loading ssl/d1_lib.c +0 −16 Original line number Diff line number Diff line Loading @@ -132,16 +132,6 @@ int dtls1_new(SSL *s) memset(d1,0, sizeof *d1); /* d1->handshake_epoch=0; */ #if defined(OPENSSL_SYS_VMS) || defined(VMS_TEST) d1->bitmap.length=64; #else d1->bitmap.length=sizeof(d1->bitmap.map) * 8; #endif pq_64bit_init(&(d1->bitmap.map)); pq_64bit_init(&(d1->bitmap.max_seq_num)); pq_64bit_init(&(d1->next_bitmap.map)); pq_64bit_init(&(d1->next_bitmap.max_seq_num)); d1->unprocessed_rcds.q=pqueue_new(); d1->processed_rcds.q=pqueue_new(); Loading Loading @@ -208,12 +198,6 @@ void dtls1_free(SSL *s) } pqueue_free(s->d1->sent_messages); pq_64bit_free(&(s->d1->bitmap.map)); pq_64bit_free(&(s->d1->bitmap.max_seq_num)); pq_64bit_free(&(s->d1->next_bitmap.map)); pq_64bit_free(&(s->d1->next_bitmap.max_seq_num)); OPENSSL_free(s->d1); } Loading Loading
crypto/pqueue/pq_compat.h +1 −0 Original line number Diff line number Diff line #error "to be deleted" /* crypto/pqueue/pqueue_compat.h */ /* * DTLS implementation written by Nagendra Modadugu Loading
crypto/pqueue/pqueue.c +16 −13 Original line number Diff line number Diff line Loading @@ -68,13 +68,12 @@ typedef struct _pqueue } pqueue_s; pitem * pitem_new(PQ_64BIT priority, void *data) pitem_new(unsigned char *prio64be, void *data) { pitem *item = (pitem *) OPENSSL_malloc(sizeof(pitem)); if (item == NULL) return NULL; pq_64bit_init(&(item->priority)); pq_64bit_assign(&item->priority, &priority); memcpy(item->priority,prio64be,sizeof(item->priority)); item->data = data; item->next = NULL; Loading @@ -87,7 +86,6 @@ pitem_free(pitem *item) { if (item == NULL) return; pq_64bit_free(&(item->priority)); OPENSSL_free(item); } Loading Loading @@ -124,7 +122,10 @@ pqueue_insert(pqueue_s *pq, pitem *item) next != NULL; curr = next, next = next->next) { if (pq_64bit_gt(&(next->priority), &(item->priority))) /* we can compare 64-bit value in big-endian encoding * with memcmp:-) */ int cmp = memcmp(next->priority, item->priority,8); if (cmp > 0) /* next > item */ { item->next = next; Loading @@ -135,8 +136,8 @@ pqueue_insert(pqueue_s *pq, pitem *item) return item; } /* duplicates not allowed */ if (pq_64bit_eq(&(item->priority), &(next->priority))) else if (cmp == 0) /* duplicates not allowed */ return NULL; } Loading Loading @@ -164,7 +165,7 @@ pqueue_pop(pqueue_s *pq) } pitem * pqueue_find(pqueue_s *pq, PQ_64BIT priority) pqueue_find(pqueue_s *pq, unsigned char *prio64be) { pitem *next, *prev = NULL; pitem *found = NULL; Loading @@ -175,7 +176,7 @@ pqueue_find(pqueue_s *pq, PQ_64BIT priority) for ( next = pq->items; next->next != NULL; prev = next, next = next->next) { if ( pq_64bit_eq(&(next->priority), &priority)) if ( memcmp(next->priority, prio64be,8) == 0) { found = next; break; Loading @@ -183,7 +184,7 @@ pqueue_find(pqueue_s *pq, PQ_64BIT priority) } /* check the one last node */ if ( pq_64bit_eq(&(next->priority), &priority)) if ( memcpy(next->priority, prio64be,8) ==0) found = next; if ( ! found) Loading @@ -199,7 +200,6 @@ pqueue_find(pqueue_s *pq, PQ_64BIT priority) return found; } #if PQ_64BIT_IS_INTEGER void pqueue_print(pqueue_s *pq) { Loading @@ -207,11 +207,14 @@ pqueue_print(pqueue_s *pq) while(item != NULL) { printf("item\t%lld\n", item->priority); printf("item\t%02x%02x%02x%02x%02x%02x%02x%02x\n", item->priority[0],item->priority[1], item->priority[2],item->priority[3], item->priority[4],item->priority[5], item->priority[6],item->priority[7]); item = item->next; } } #endif pitem * pqueue_iterator(pqueue_s *pq) Loading
crypto/pqueue/pqueue.h +3 −5 Original line number Diff line number Diff line Loading @@ -64,20 +64,18 @@ #include <stdlib.h> #include <string.h> #include <openssl/pq_compat.h> typedef struct _pqueue *pqueue; typedef struct _pitem { PQ_64BIT priority; unsigned char priority[8]; /* 64-bit value in big-endian encoding */ void *data; struct _pitem *next; } pitem; typedef struct _pitem *piterator; pitem *pitem_new(PQ_64BIT priority, void *data); pitem *pitem_new(unsigned char *prio64be, void *data); void pitem_free(pitem *item); pqueue pqueue_new(void); Loading @@ -86,7 +84,7 @@ void pqueue_free(pqueue pq); pitem *pqueue_insert(pqueue pq, pitem *item); pitem *pqueue_peek(pqueue pq); pitem *pqueue_pop(pqueue pq); pitem *pqueue_find(pqueue pq, PQ_64BIT priority); pitem *pqueue_find(pqueue pq, unsigned char *prio64be); pitem *pqueue_iterator(pqueue pq); pitem *pqueue_next(piterator *iter); Loading
ssl/d1_both.c +15 −16 Original line number Diff line number Diff line Loading @@ -442,7 +442,7 @@ dtls1_buffer_handshake_fragment(SSL *s, struct hm_header_st* msg_hdr) { hm_fragment *frag = NULL; pitem *item = NULL; PQ_64BIT seq64; unsigned char seq64be[8]; frag = dtls1_hm_fragment_new(msg_hdr->frag_len); if ( frag == NULL) Loading @@ -453,15 +453,14 @@ dtls1_buffer_handshake_fragment(SSL *s, struct hm_header_st* msg_hdr) memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr)); pq_64bit_init(&seq64); pq_64bit_assign_word(&seq64, msg_hdr->seq); memset(seq64be,0,sizeof(seq64be)); seq64be[6] = (unsigned char)(msg_hdr->seq>>8); seq64be[7] = (unsigned char)(msg_hdr->seq); item = pitem_new(seq64, frag); item = pitem_new(seq64be, frag); if ( item == NULL) goto err; pq_64bit_free(&seq64); pqueue_insert(s->d1->buffered_messages, item); return 1; Loading Loading @@ -1043,7 +1042,7 @@ dtls1_buffer_message(SSL *s, int is_ccs) { pitem *item; hm_fragment *frag; PQ_64BIT seq64; unsigned char seq64be[8]; /* this function is called immediately after a message has * been serialized */ Loading Loading @@ -1071,11 +1070,11 @@ dtls1_buffer_message(SSL *s, int is_ccs) frag->msg_header.frag_len = s->d1->w_msg_hdr.msg_len; frag->msg_header.is_ccs = is_ccs; pq_64bit_init(&seq64); pq_64bit_assign_word(&seq64, frag->msg_header.seq); memset(seq64be,0,sizeof(seq64be)); seq64be[6] = (unsigned char)(frag->msg_header.seq>>8); seq64be[7] = (unsigned char)(frag->msg_header.seq); item = pitem_new(seq64, frag); pq_64bit_free(&seq64); item = pitem_new(seq64be, frag); if ( item == NULL) { dtls1_hm_fragment_free(frag); Loading @@ -1101,7 +1100,7 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, pitem *item; hm_fragment *frag ; unsigned long header_length; PQ_64BIT seq64; unsigned char seq64be[8]; /* OPENSSL_assert(s->init_num == 0); Loading @@ -1109,11 +1108,11 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, */ /* XDTLS: the requested message ought to be found, otherwise error */ pq_64bit_init(&seq64); pq_64bit_assign_word(&seq64, seq); memset(seq64be,0,sizeof(seq64be)); seq64be[6] = (unsigned char)(seq>>8); seq64be[7] = (unsigned char)seq; item = pqueue_find(s->d1->sent_messages, seq64); pq_64bit_free(&seq64); item = pqueue_find(s->d1->sent_messages, seq64be); if ( item == NULL) { fprintf(stderr, "retransmit: message %d non-existant\n", seq); Loading
ssl/d1_lib.c +0 −16 Original line number Diff line number Diff line Loading @@ -132,16 +132,6 @@ int dtls1_new(SSL *s) memset(d1,0, sizeof *d1); /* d1->handshake_epoch=0; */ #if defined(OPENSSL_SYS_VMS) || defined(VMS_TEST) d1->bitmap.length=64; #else d1->bitmap.length=sizeof(d1->bitmap.map) * 8; #endif pq_64bit_init(&(d1->bitmap.map)); pq_64bit_init(&(d1->bitmap.max_seq_num)); pq_64bit_init(&(d1->next_bitmap.map)); pq_64bit_init(&(d1->next_bitmap.max_seq_num)); d1->unprocessed_rcds.q=pqueue_new(); d1->processed_rcds.q=pqueue_new(); Loading Loading @@ -208,12 +198,6 @@ void dtls1_free(SSL *s) } pqueue_free(s->d1->sent_messages); pq_64bit_free(&(s->d1->bitmap.map)); pq_64bit_free(&(s->d1->bitmap.max_seq_num)); pq_64bit_free(&(s->d1->next_bitmap.map)); pq_64bit_free(&(s->d1->next_bitmap.max_seq_num)); OPENSSL_free(s->d1); } Loading