-/* $OpenBSD: d1_srvr.c,v 1.36 2014/08/10 14:42:56 jsing Exp $ */
+/* $OpenBSD: d1_srvr.c,v 1.37 2014/08/24 14:36:45 jsing Exp $ */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
{
unsigned char *buf;
unsigned char *p, *d;
- int i;
unsigned int sl;
unsigned long l;
/* put the cipher */
if (s->s3->tmp.new_cipher == NULL)
return -1;
- i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p);
- p += i;
+ s2n(ssl3_cipher_get_value(s->s3->tmp.new_cipher), p);
/* put the compression method */
*(p++) = 0;
-/* $OpenBSD: s3_lib.c,v 1.78 2014/08/23 15:37:38 jsing Exp $ */
+/* $OpenBSD: s3_lib.c,v 1.79 2014/08/24 14:36:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
return (NULL);
}
+uint16_t
+ssl3_cipher_get_value(const SSL_CIPHER *c)
+{
+ return (c->id & SSL3_CK_VALUE_MASK);
+}
+
int
ssl3_pending(const SSL *s)
{
return (1);
}
-int
-ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
-{
- long l;
-
- if (p != NULL) {
- l = c->id;
- if ((l & 0xff000000) != 0x03000000)
- return (0);
- p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
- p[1] = ((unsigned char)(l)) & 0xFF;
- }
- return (2);
-}
-
SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
STACK_OF(SSL_CIPHER) *srvr)
{
-/* $OpenBSD: s3_srvr.c,v 1.81 2014/08/11 04:46:42 miod Exp $ */
+/* $OpenBSD: s3_srvr.c,v 1.82 2014/08/24 14:36:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
{
unsigned char *buf;
unsigned char *p, *d;
- int i, sl;
unsigned long l;
+ int sl;
if (s->state == SSL3_ST_SW_SRVR_HELLO_A) {
buf = (unsigned char *)s->init_buf->data;
p += sl;
/* put the cipher */
- i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p);
- p += i;
+ s2n(ssl3_cipher_get_value(s->s3->tmp.new_cipher), p);
/* put the compression method */
*(p++) = 0;
-/* $OpenBSD: d1_srvr.c,v 1.36 2014/08/10 14:42:56 jsing Exp $ */
+/* $OpenBSD: d1_srvr.c,v 1.37 2014/08/24 14:36:45 jsing Exp $ */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
{
unsigned char *buf;
unsigned char *p, *d;
- int i;
unsigned int sl;
unsigned long l;
/* put the cipher */
if (s->s3->tmp.new_cipher == NULL)
return -1;
- i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p);
- p += i;
+ s2n(ssl3_cipher_get_value(s->s3->tmp.new_cipher), p);
/* put the compression method */
*(p++) = 0;
-/* $OpenBSD: s3_lib.c,v 1.78 2014/08/23 15:37:38 jsing Exp $ */
+/* $OpenBSD: s3_lib.c,v 1.79 2014/08/24 14:36:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
return (NULL);
}
+uint16_t
+ssl3_cipher_get_value(const SSL_CIPHER *c)
+{
+ return (c->id & SSL3_CK_VALUE_MASK);
+}
+
int
ssl3_pending(const SSL *s)
{
return (1);
}
-int
-ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
-{
- long l;
-
- if (p != NULL) {
- l = c->id;
- if ((l & 0xff000000) != 0x03000000)
- return (0);
- p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
- p[1] = ((unsigned char)(l)) & 0xFF;
- }
- return (2);
-}
-
SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
STACK_OF(SSL_CIPHER) *srvr)
{
-/* $OpenBSD: s3_srvr.c,v 1.81 2014/08/11 04:46:42 miod Exp $ */
+/* $OpenBSD: s3_srvr.c,v 1.82 2014/08/24 14:36:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
{
unsigned char *buf;
unsigned char *p, *d;
- int i, sl;
unsigned long l;
+ int sl;
if (s->state == SSL3_ST_SW_SRVR_HELLO_A) {
buf = (unsigned char *)s->init_buf->data;
p += sl;
/* put the cipher */
- i = ssl3_put_cipher_by_char(s->s3->tmp.new_cipher, p);
- p += i;
+ s2n(ssl3_cipher_get_value(s->s3->tmp.new_cipher), p);
/* put the compression method */
*(p++) = 0;
-/* $OpenBSD: ssl_lib.c,v 1.82 2014/08/23 14:52:41 jsing Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.83 2014/08/24 14:36:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
if ((c->algorithm_ssl & SSL_TLSV1_2) &&
(TLS1_get_client_version(s) < TLS1_2_VERSION))
continue;
- p += ssl3_put_cipher_by_char(c, p);
+
+ s2n(ssl3_cipher_get_value(c), p);
}
/*
static SSL_CIPHER scsv = {
0, NULL, SSL3_CK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- p += ssl3_put_cipher_by_char(&scsv, p);
+ s2n(ssl3_cipher_get_value(&scsv), p);
}
return (p - q);
-/* $OpenBSD: ssl_locl.h,v 1.66 2014/08/23 14:52:41 jsing Exp $ */
+/* $OpenBSD: ssl_locl.h,v 1.67 2014/08/24 14:36:46 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
#define SSL_MAX_DIGEST 6
#define SSL3_CK_ID 0x03000000
+#define SSL3_CK_VALUE_MASK 0x0000ffff
#define TLS1_PRF_DGST_MASK (0xff << TLS1_PRF_DGST_SHIFT)
int ssl_verify_alarm_type(long type);
void ssl_load_ciphers(void);
-int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
void ssl3_init_finished_mac(SSL *s);
int ssl3_send_server_certificate(SSL *s);
int ssl3_send_newsession_ticket(SSL *s);
int ssl3_num_ciphers(void);
const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id);
+uint16_t ssl3_cipher_get_value(const SSL_CIPHER *c);
int ssl3_renegotiate(SSL *ssl);
int ssl3_renegotiate_check(SSL *ssl);
-/* $OpenBSD: ssl_lib.c,v 1.82 2014/08/23 14:52:41 jsing Exp $ */
+/* $OpenBSD: ssl_lib.c,v 1.83 2014/08/24 14:36:45 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
if ((c->algorithm_ssl & SSL_TLSV1_2) &&
(TLS1_get_client_version(s) < TLS1_2_VERSION))
continue;
- p += ssl3_put_cipher_by_char(c, p);
+
+ s2n(ssl3_cipher_get_value(c), p);
}
/*
static SSL_CIPHER scsv = {
0, NULL, SSL3_CK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- p += ssl3_put_cipher_by_char(&scsv, p);
+ s2n(ssl3_cipher_get_value(&scsv), p);
}
return (p - q);
-/* $OpenBSD: ssl_locl.h,v 1.66 2014/08/23 14:52:41 jsing Exp $ */
+/* $OpenBSD: ssl_locl.h,v 1.67 2014/08/24 14:36:46 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
#define SSL_MAX_DIGEST 6
#define SSL3_CK_ID 0x03000000
+#define SSL3_CK_VALUE_MASK 0x0000ffff
#define TLS1_PRF_DGST_MASK (0xff << TLS1_PRF_DGST_SHIFT)
int ssl_verify_alarm_type(long type);
void ssl_load_ciphers(void);
-int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
void ssl3_init_finished_mac(SSL *s);
int ssl3_send_server_certificate(SSL *s);
int ssl3_send_newsession_ticket(SSL *s);
int ssl3_num_ciphers(void);
const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id);
+uint16_t ssl3_cipher_get_value(const SSL_CIPHER *c);
int ssl3_renegotiate(SSL *ssl);
int ssl3_renegotiate_check(SSL *ssl);