|
@@ -65,7 +65,7 @@ static void tls_clear_cipher ( struct tls_session *tls,
|
65
|
65
|
* TLS uses 24-bit integers in several places, which are awkward to
|
66
|
66
|
* parse in C.
|
67
|
67
|
*/
|
68
|
|
-static unsigned long tls_uint24 ( uint8_t field24[3] ) {
|
|
68
|
+static unsigned long tls_uint24 ( const uint8_t field24[3] ) {
|
69
|
69
|
return ( ( field24[0] << 16 ) + ( field24[1] << 8 ) + field24[2] );
|
70
|
70
|
}
|
71
|
71
|
|
|
@@ -874,7 +874,7 @@ static int tls_send_finished ( struct tls_session *tls ) {
|
874
|
874
|
* @ret rc Return status code
|
875
|
875
|
*/
|
876
|
876
|
static int tls_new_change_cipher ( struct tls_session *tls,
|
877
|
|
- void *data, size_t len ) {
|
|
877
|
+ const void *data, size_t len ) {
|
878
|
878
|
int rc;
|
879
|
879
|
|
880
|
880
|
if ( ( len != 1 ) || ( *( ( uint8_t * ) data ) != 1 ) ) {
|
|
@@ -902,13 +902,14 @@ static int tls_new_change_cipher ( struct tls_session *tls,
|
902
|
902
|
* @v len Length of plaintext record
|
903
|
903
|
* @ret rc Return status code
|
904
|
904
|
*/
|
905
|
|
-static int tls_new_alert ( struct tls_session *tls, void *data, size_t len ) {
|
906
|
|
- struct {
|
|
905
|
+static int tls_new_alert ( struct tls_session *tls, const void *data,
|
|
906
|
+ size_t len ) {
|
|
907
|
+ const struct {
|
907
|
908
|
uint8_t level;
|
908
|
909
|
uint8_t description;
|
909
|
910
|
char next[0];
|
910
|
911
|
} __attribute__ (( packed )) *alert = data;
|
911
|
|
- void *end = alert->next;
|
|
912
|
+ const void *end = alert->next;
|
912
|
913
|
|
913
|
914
|
/* Sanity check */
|
914
|
915
|
if ( end != ( data + len ) ) {
|
|
@@ -942,20 +943,20 @@ static int tls_new_alert ( struct tls_session *tls, void *data, size_t len ) {
|
942
|
943
|
* @ret rc Return status code
|
943
|
944
|
*/
|
944
|
945
|
static int tls_new_server_hello ( struct tls_session *tls,
|
945
|
|
- void *data, size_t len ) {
|
946
|
|
- struct {
|
|
946
|
+ const void *data, size_t len ) {
|
|
947
|
+ const struct {
|
947
|
948
|
uint16_t version;
|
948
|
949
|
uint8_t random[32];
|
949
|
950
|
uint8_t session_id_len;
|
950
|
951
|
char next[0];
|
951
|
952
|
} __attribute__ (( packed )) *hello_a = data;
|
952
|
|
- struct {
|
|
953
|
+ const struct {
|
953
|
954
|
uint8_t session_id[hello_a->session_id_len];
|
954
|
955
|
uint16_t cipher_suite;
|
955
|
956
|
uint8_t compression_method;
|
956
|
957
|
char next[0];
|
957
|
958
|
} __attribute__ (( packed )) *hello_b = ( void * ) &hello_a->next;
|
958
|
|
- void *end = hello_b->next;
|
|
959
|
+ const void *end = hello_b->next;
|
959
|
960
|
uint16_t version;
|
960
|
961
|
int rc;
|
961
|
962
|
|
|
@@ -1008,18 +1009,18 @@ static int tls_new_server_hello ( struct tls_session *tls,
|
1008
|
1009
|
* @ret rc Return status code
|
1009
|
1010
|
*/
|
1010
|
1011
|
static int tls_new_certificate ( struct tls_session *tls,
|
1011
|
|
- void *data, size_t len ) {
|
1012
|
|
- struct {
|
|
1012
|
+ const void *data, size_t len ) {
|
|
1013
|
+ const struct {
|
1013
|
1014
|
uint8_t length[3];
|
1014
|
1015
|
uint8_t certificates[0];
|
1015
|
1016
|
} __attribute__ (( packed )) *certificate = data;
|
1016
|
|
- struct {
|
|
1017
|
+ const struct {
|
1017
|
1018
|
uint8_t length[3];
|
1018
|
1019
|
uint8_t certificate[0];
|
1019
|
1020
|
} __attribute__ (( packed )) *element =
|
1020
|
1021
|
( ( void * ) certificate->certificates );
|
1021
|
1022
|
size_t elements_len = tls_uint24 ( certificate->length );
|
1022
|
|
- void *end = ( certificate->certificates + elements_len );
|
|
1023
|
+ const void *end = ( certificate->certificates + elements_len );
|
1023
|
1024
|
struct asn1_cursor cursor;
|
1024
|
1025
|
int rc;
|
1025
|
1026
|
|
|
@@ -1066,7 +1067,7 @@ static int tls_new_certificate ( struct tls_session *tls,
|
1066
|
1067
|
* @ret rc Return status code
|
1067
|
1068
|
*/
|
1068
|
1069
|
static int tls_new_certificate_request ( struct tls_session *tls,
|
1069
|
|
- void *data __unused,
|
|
1070
|
+ const void *data __unused,
|
1070
|
1071
|
size_t len __unused ) {
|
1071
|
1072
|
|
1072
|
1073
|
/* We can only send an empty certificate (as mandated by
|
|
@@ -1090,11 +1091,11 @@ static int tls_new_certificate_request ( struct tls_session *tls,
|
1090
|
1091
|
* @ret rc Return status code
|
1091
|
1092
|
*/
|
1092
|
1093
|
static int tls_new_server_hello_done ( struct tls_session *tls,
|
1093
|
|
- void *data, size_t len ) {
|
1094
|
|
- struct {
|
|
1094
|
+ const void *data, size_t len ) {
|
|
1095
|
+ const struct {
|
1095
|
1096
|
char next[0];
|
1096
|
1097
|
} __attribute__ (( packed )) *hello_done = data;
|
1097
|
|
- void *end = hello_done->next;
|
|
1098
|
+ const void *end = hello_done->next;
|
1098
|
1099
|
|
1099
|
1100
|
/* Sanity check */
|
1100
|
1101
|
if ( end != ( data + len ) ) {
|
|
@@ -1122,12 +1123,12 @@ static int tls_new_server_hello_done ( struct tls_session *tls,
|
1122
|
1123
|
* @ret rc Return status code
|
1123
|
1124
|
*/
|
1124
|
1125
|
static int tls_new_finished ( struct tls_session *tls,
|
1125
|
|
- void *data, size_t len ) {
|
1126
|
|
- struct {
|
|
1126
|
+ const void *data, size_t len ) {
|
|
1127
|
+ const struct {
|
1127
|
1128
|
uint8_t verify_data[12];
|
1128
|
1129
|
char next[0];
|
1129
|
1130
|
} __attribute__ (( packed )) *finished = data;
|
1130
|
|
- void *end = finished->next;
|
|
1131
|
+ const void *end = finished->next;
|
1131
|
1132
|
uint8_t digest[ tls_verify_handshake_len ( tls ) ];
|
1132
|
1133
|
uint8_t verify_data[ sizeof ( finished->verify_data ) ];
|
1133
|
1134
|
|
|
@@ -1167,12 +1168,12 @@ static int tls_new_finished ( struct tls_session *tls,
|
1167
|
1168
|
* @ret rc Return status code
|
1168
|
1169
|
*/
|
1169
|
1170
|
static int tls_new_handshake ( struct tls_session *tls,
|
1170
|
|
- void *data, size_t len ) {
|
1171
|
|
- void *end = ( data + len );
|
|
1171
|
+ const void *data, size_t len ) {
|
|
1172
|
+ const void *end = ( data + len );
|
1172
|
1173
|
int rc;
|
1173
|
1174
|
|
1174
|
1175
|
while ( data != end ) {
|
1175
|
|
- struct {
|
|
1176
|
+ const struct {
|
1176
|
1177
|
uint8_t type;
|
1177
|
1178
|
uint8_t length[3];
|
1178
|
1179
|
uint8_t payload[0];
|
|
@@ -1242,8 +1243,8 @@ static int tls_new_handshake ( struct tls_session *tls,
|
1242
|
1243
|
* @v len Length of plaintext record
|
1243
|
1244
|
* @ret rc Return status code
|
1244
|
1245
|
*/
|
1245
|
|
-static int tls_new_record ( struct tls_session *tls,
|
1246
|
|
- unsigned int type, void *data, size_t len ) {
|
|
1246
|
+static int tls_new_record ( struct tls_session *tls, unsigned int type,
|
|
1247
|
+ const void *data, size_t len ) {
|
1247
|
1248
|
|
1248
|
1249
|
switch ( type ) {
|
1249
|
1250
|
case TLS_TYPE_CHANGE_CIPHER:
|
|
@@ -1588,7 +1589,8 @@ static int tls_split_block ( struct tls_session *tls,
|
1588
|
1589
|
* @ret rc Return status code
|
1589
|
1590
|
*/
|
1590
|
1591
|
static int tls_new_ciphertext ( struct tls_session *tls,
|
1591
|
|
- struct tls_header *tlshdr, void *ciphertext ) {
|
|
1592
|
+ struct tls_header *tlshdr,
|
|
1593
|
+ const void *ciphertext ) {
|
1592
|
1594
|
struct tls_header plaintext_tlshdr;
|
1593
|
1595
|
struct tls_cipherspec *cipherspec = &tls->rx_cipherspec;
|
1594
|
1596
|
struct cipher_algorithm *cipher = cipherspec->suite->cipher;
|