2 * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, int len)
17 if (SSL_in_init(s) && !ossl_statem_get_in_handshake(s)) {
18 i = s->handshake_func(s);
22 SSLerr(SSL_F_DTLS1_WRITE_APP_DATA_BYTES,
23 SSL_R_SSL_HANDSHAKE_FAILURE);
28 if (len > SSL3_RT_MAX_PLAIN_LENGTH) {
29 SSLerr(SSL_F_DTLS1_WRITE_APP_DATA_BYTES, SSL_R_DTLS_MESSAGE_TOO_BIG);
33 i = dtls1_write_bytes(s, type, buf_, len);
37 int dtls1_dispatch_alert(SSL *s)
40 void (*cb) (const SSL *ssl, int type, int val) = NULL;
41 unsigned char buf[DTLS1_AL_HEADER_LENGTH];
42 unsigned char *ptr = &buf[0];
44 s->s3->alert_dispatch = 0;
46 memset(buf, 0, sizeof(buf));
47 *ptr++ = s->s3->send_alert[0];
48 *ptr++ = s->s3->send_alert[1];
50 #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
51 if (s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE) {
52 s2n(s->d1->handshake_read_seq, ptr);
53 l2n3(s->d1->r_msg_hdr.frag_off, ptr);
57 i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), 0);
59 s->s3->alert_dispatch = 1;
60 /* fprintf( stderr, "not done with alert\n" ); */
62 if (s->s3->send_alert[0] == SSL3_AL_FATAL
63 #ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
64 || s->s3->send_alert[1] == DTLS1_AD_MISSING_HANDSHAKE_MESSAGE
67 (void)BIO_flush(s->wbio);
70 s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert,
71 2, s, s->msg_callback_arg);
73 if (s->info_callback != NULL)
74 cb = s->info_callback;
75 else if (s->ctx->info_callback != NULL)
76 cb = s->ctx->info_callback;
79 j = (s->s3->send_alert[0] << 8) | s->s3->send_alert[1];
80 cb(s, SSL_CB_WRITE_ALERT, j);