-/* $OpenBSD: s3_both.c,v 1.36 2014/12/14 15:30:50 jsing Exp $ */
+/* $OpenBSD: s3_both.c,v 1.37 2014/12/14 21:49:29 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
ssl3_setup_read_buffer(SSL *s)
{
unsigned char *p;
- size_t len, align = 0, headerlen;
+ size_t len, align, headerlen;
if (SSL_IS_DTLS(s))
headerlen = DTLS1_RT_HEADER_LENGTH;
else
headerlen = SSL3_RT_HEADER_LENGTH;
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (-SSL3_RT_HEADER_LENGTH)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (-SSL3_RT_HEADER_LENGTH) & (SSL3_ALIGN_PAYLOAD - 1);
if (s->s3->rbuf.buf == NULL) {
len = SSL3_RT_MAX_PLAIN_LENGTH +
ssl3_setup_write_buffer(SSL *s)
{
unsigned char *p;
- size_t len, align = 0, headerlen;
+ size_t len, align, headerlen;
if (SSL_IS_DTLS(s))
headerlen = DTLS1_RT_HEADER_LENGTH + 1;
else
headerlen = SSL3_RT_HEADER_LENGTH;
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (-SSL3_RT_HEADER_LENGTH)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (-SSL3_RT_HEADER_LENGTH) & (SSL3_ALIGN_PAYLOAD - 1);
if (s->s3->wbuf.buf == NULL) {
len = s->max_send_fragment +
-/* $OpenBSD: s3_pkt.c,v 1.53 2014/12/14 15:30:50 jsing Exp $ */
+/* $OpenBSD: s3_pkt.c,v 1.54 2014/12/14 21:49:29 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
ssl3_read_n(SSL *s, int n, int max, int extend)
{
int i, len, left;
- long align = 0;
+ size_t align;
unsigned char *pkt;
SSL3_BUFFER *rb;
return -1;
left = rb->left;
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (long)rb->buf + SSL3_RT_HEADER_LENGTH;
- align = (-align)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH;
+ align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
if (!extend) {
/* start with empty packet ... */
int i, mac_size, clear = 0;
int prefix_len = 0;
int eivlen;
- long align = 0;
+ size_t align;
SSL3_RECORD *wr;
SSL3_BUFFER *wb = &(s->s3->wbuf);
SSL_SESSION *sess;
}
if (create_empty_fragment) {
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
/* extra fragment would be couple of cipher blocks,
* which would be multiple of SSL3_ALIGN_PAYLOAD, so
* if we want to align the real payload, then we can
* just pretent we simply have two headers. */
- align = (long)wb->buf + 2*SSL3_RT_HEADER_LENGTH;
- align = (-align)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (size_t)wb->buf + 2 * SSL3_RT_HEADER_LENGTH;
+ align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+
p = wb->buf + align;
wb->offset = align;
} else if (prefix_len) {
p = wb->buf + wb->offset + prefix_len;
} else {
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (long)wb->buf + SSL3_RT_HEADER_LENGTH;
- align = (-align)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (size_t)wb->buf + SSL3_RT_HEADER_LENGTH;
+ align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+
p = wb->buf + align;
wb->offset = align;
}
-/* $OpenBSD: s3_both.c,v 1.36 2014/12/14 15:30:50 jsing Exp $ */
+/* $OpenBSD: s3_both.c,v 1.37 2014/12/14 21:49:29 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
ssl3_setup_read_buffer(SSL *s)
{
unsigned char *p;
- size_t len, align = 0, headerlen;
+ size_t len, align, headerlen;
if (SSL_IS_DTLS(s))
headerlen = DTLS1_RT_HEADER_LENGTH;
else
headerlen = SSL3_RT_HEADER_LENGTH;
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (-SSL3_RT_HEADER_LENGTH)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (-SSL3_RT_HEADER_LENGTH) & (SSL3_ALIGN_PAYLOAD - 1);
if (s->s3->rbuf.buf == NULL) {
len = SSL3_RT_MAX_PLAIN_LENGTH +
ssl3_setup_write_buffer(SSL *s)
{
unsigned char *p;
- size_t len, align = 0, headerlen;
+ size_t len, align, headerlen;
if (SSL_IS_DTLS(s))
headerlen = DTLS1_RT_HEADER_LENGTH + 1;
else
headerlen = SSL3_RT_HEADER_LENGTH;
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (-SSL3_RT_HEADER_LENGTH)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (-SSL3_RT_HEADER_LENGTH) & (SSL3_ALIGN_PAYLOAD - 1);
if (s->s3->wbuf.buf == NULL) {
len = s->max_send_fragment +
-/* $OpenBSD: s3_pkt.c,v 1.53 2014/12/14 15:30:50 jsing Exp $ */
+/* $OpenBSD: s3_pkt.c,v 1.54 2014/12/14 21:49:29 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
ssl3_read_n(SSL *s, int n, int max, int extend)
{
int i, len, left;
- long align = 0;
+ size_t align;
unsigned char *pkt;
SSL3_BUFFER *rb;
return -1;
left = rb->left;
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (long)rb->buf + SSL3_RT_HEADER_LENGTH;
- align = (-align)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH;
+ align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
if (!extend) {
/* start with empty packet ... */
int i, mac_size, clear = 0;
int prefix_len = 0;
int eivlen;
- long align = 0;
+ size_t align;
SSL3_RECORD *wr;
SSL3_BUFFER *wb = &(s->s3->wbuf);
SSL_SESSION *sess;
}
if (create_empty_fragment) {
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
/* extra fragment would be couple of cipher blocks,
* which would be multiple of SSL3_ALIGN_PAYLOAD, so
* if we want to align the real payload, then we can
* just pretent we simply have two headers. */
- align = (long)wb->buf + 2*SSL3_RT_HEADER_LENGTH;
- align = (-align)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (size_t)wb->buf + 2 * SSL3_RT_HEADER_LENGTH;
+ align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+
p = wb->buf + align;
wb->offset = align;
} else if (prefix_len) {
p = wb->buf + wb->offset + prefix_len;
} else {
-#if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0
- align = (long)wb->buf + SSL3_RT_HEADER_LENGTH;
- align = (-align)&(SSL3_ALIGN_PAYLOAD - 1);
-#endif
+ align = (size_t)wb->buf + SSL3_RT_HEADER_LENGTH;
+ align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+
p = wb->buf + align;
wb->offset = align;
}
-/* $OpenBSD: ssl3.h,v 1.32 2014/12/14 16:07:26 jsing Exp $ */
+/* $OpenBSD: ssl3.h,v 1.33 2014/12/14 21:49:29 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
#define SSL3_RT_HEADER_LENGTH 5
#define SSL3_HM_HEADER_LENGTH 4
-#ifndef SSL3_ALIGN_PAYLOAD
- /* Some will argue that this increases memory footprint, but it's
- * not actually true. Point is that malloc has to return at least
- * 64-bit aligned pointers, meaning that allocating 5 bytes wastes
- * 3 bytes in either case. Suggested pre-gaping simply moves these
- * wasted bytes from the end of allocated region to its front,
- * but makes data payload aligned, which improves performance:-) */
-# define SSL3_ALIGN_PAYLOAD 8
-#else
-# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0
-# error "insane SSL3_ALIGN_PAYLOAD"
-# undef SSL3_ALIGN_PAYLOAD
-# endif
-#endif
+#define SSL3_ALIGN_PAYLOAD 8
/* This is the maximum MAC (digest) size used by the SSL library.
* Currently maximum of 20 is used by SHA1, but we reserve for
-/* $OpenBSD: ssl3.h,v 1.32 2014/12/14 16:07:26 jsing Exp $ */
+/* $OpenBSD: ssl3.h,v 1.33 2014/12/14 21:49:29 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
#define SSL3_RT_HEADER_LENGTH 5
#define SSL3_HM_HEADER_LENGTH 4
-#ifndef SSL3_ALIGN_PAYLOAD
- /* Some will argue that this increases memory footprint, but it's
- * not actually true. Point is that malloc has to return at least
- * 64-bit aligned pointers, meaning that allocating 5 bytes wastes
- * 3 bytes in either case. Suggested pre-gaping simply moves these
- * wasted bytes from the end of allocated region to its front,
- * but makes data payload aligned, which improves performance:-) */
-# define SSL3_ALIGN_PAYLOAD 8
-#else
-# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0
-# error "insane SSL3_ALIGN_PAYLOAD"
-# undef SSL3_ALIGN_PAYLOAD
-# endif
-#endif
+#define SSL3_ALIGN_PAYLOAD 8
/* This is the maximum MAC (digest) size used by the SSL library.
* Currently maximum of 20 is used by SHA1, but we reserve for