66 #ifdef HAVE_WTLS_OPENSSL 67 #include <openssl/x509.h> 68 #include <openssl/des.h> 70 #include <openssl/rc5.h> 72 #error "your OpenSSL installation lacks RC5 algorithm support" 78 #define BLOCKLENGTH 64 118 {
"SHA-XOR-40", 0, 5},
124 X509 *x509_cert = NULL;
125 RSA *private_key = NULL;
130 extern unsigned char *MD5(
const unsigned char *d,
size_t n,
unsigned char 132 extern unsigned char *stateName(
int state);
144 Octstr *wtls_get_certificate(
void);
145 int isSupportedKeyEx(
int keyExId);
146 void add_all_handshake_data(
WTLSMachine * wtls_machine,
List * pdu_list);
154 int len, padLen = 0, macSize, recordType, block, refresh;
155 Octstr *openText, *MAContent, *tempData, *result;
158 if (
payload->seqNum && wtls_machine->client_seq_num >
payload->seqNum) {
160 "Out of sequence packet received (p: %d < %d :w). Dropping datagram.",
161 payload->seqNum, wtls_machine->client_seq_num);
164 wtls_machine->client_seq_num =
payload->seqNum;
165 refresh = 1 << wtls_machine->key_refresh;
166 if (wtls_machine->last_refresh < 0 || (wtls_machine->last_refresh +
168 wtls_machine->client_seq_num))
170 switch (wtls_machine->bulk_cipher_algorithm) {
178 openText = wtls_rc5(
payload->
data, wtls_machine, RC5_DECRYPT);
183 openText = wtls_des(
payload->
data, wtls_machine, DES_DECRYPT);
187 cipherName(cipher, wtls_machine->bulk_cipher_algorithm);
189 "wtls_decrypt: Unsupported bulk cipher algorithm (%s).",
196 recordType |=
payload->snMode << 6;
197 recordType |=
payload->cipher << 5;
198 recordType |=
payload->reserved << 4;
202 block = bulk_table[wtls_machine->bulk_cipher_algorithm].
block_size;
204 padLen = *(p + len - 1);
205 if (padLen >= block || padLen != *(p + len - 2))
208 macSize = hash_table[wtls_machine->mac_algorithm].
mac_size;
211 pack_int16(tempData, 0, wtls_machine->client_seq_num);
213 pack_int16(tempData, 3, len - macSize - padLen);
215 MAContent = wtls_hmac_hash(wtls_machine->client_write_MAC_secret,
216 tempData, wtls_machine->mac_algorithm);
222 error(0,
"wtls_decrypt: Rejected packet due to bad MAC");
240 char *tempPadding = NULL;
241 int paddingLength, macSize, blockLength, bufferLength, refresh;
244 refresh = 1 << wtls_machine->key_refresh;
245 if (!(wtls_machine->server_seq_num % refresh))
255 pack_int16(tempData, 0, wtls_machine->server_seq_num);
262 wtls_hmac_hash(wtls_machine->server_write_MAC_secret, tempData,
263 wtls_machine->mac_algorithm);
266 macSize = hash_table[wtls_machine->mac_algorithm].
mac_size;
268 bulk_table[wtls_machine->bulk_cipher_algorithm].
block_size;
271 blockLength - ((bufferLength + macSize + 1) % blockLength);
276 if (paddingLength > 0) {
278 tempPadding = gw_malloc(paddingLength);
279 for (i = 0; i < paddingLength; i++) {
282 tempPadding[i] = paddingLength;
285 gw_free(tempPadding);
291 switch (wtls_machine->bulk_cipher_algorithm) {
300 wtls_rc5(bufferCopy, wtls_machine, RC5_ENCRYPT);
306 wtls_des(bufferCopy, wtls_machine, DES_ENCRYPT);
311 "wtls_encrypt: Unsupported bulk cipher algorithm (%d).",
312 wtls_machine->bulk_cipher_algorithm);
313 encryptedContent = NULL;
320 return (encryptedContent);
331 strcpy(
name,
"null_k");
335 strcpy(
name,
"shared_secret");
339 strcpy(
name,
"dh_anon");
343 strcpy(
name,
"dh_anon_512");
347 strcpy(
name,
"dh_anon_768");
351 strcpy(
name,
"rsa_anon");
355 strcpy(
name,
"rsa_anon_512");
359 strcpy(
name,
"rsa_anon_768");
367 strcpy(
name,
"rsa_512");
371 strcpy(
name,
"rsa_768");
375 strcpy(
name,
"ecdh_anon");
379 strcpy(
name,
"ecdh_anon_113");
383 strcpy(
name,
"ecdh_anon_131");
387 strcpy(
name,
"ecdh_ecdsa");
396 strcpy(
name,
"NULL_bulk");
400 strcpy(
name,
"RC5_CBC_40");
404 strcpy(
name,
"RC5_CBC_56");
408 strcpy(
name,
"RC5_CBC");
412 strcpy(
name,
"DES_CBC_40");
416 strcpy(
name,
"DES_CBC");
420 strcpy(
name,
"TRIPLE_DES_CBC_EDE");
424 strcpy(
name,
"IDEA_CBC_40");
428 strcpy(
name,
"IDEA_CBC_56");
432 strcpy(
name,
"IDEA_CBC");
441 strcpy(
name,
"SHA_0");
445 strcpy(
name,
"SHA_40");
449 strcpy(
name,
"SHA_80");
453 strcpy(
name,
"SHA_NOLIMIT");
457 strcpy(
name,
"SHA_XOR_40");
461 strcpy(
name,
"MD5_80");
465 strcpy(
name,
"MD5_80");
469 strcpy(
name,
"MD5_NOLIMIT");
478 strcpy(
name,
"connection_close_notify");
482 strcpy(
name,
"session_close_notify");
486 strcpy(
name,
"no_connection");
490 strcpy(
name,
"unexpected_message");
494 strcpy(
name,
"time_required");
498 strcpy(
name,
"bad_record_mac");
502 strcpy(
name,
"decryption_failed");
506 strcpy(
name,
"record_overflow");
510 strcpy(
name,
"decompression_failure");
514 strcpy(
name,
"handshake_failure");
518 strcpy(
name,
"unsupported_certificate");
522 strcpy(
name,
"certificate_revoked");
526 strcpy(
name,
"certificate_expired");
530 strcpy(
name,
"certificate_unknown");
534 strcpy(
name,
"illegal_parameter");
538 strcpy(
name,
"unknown_ca");
542 strcpy(
name,
"access_denied");
546 strcpy(
name,
"decode_error");
550 strcpy(
name,
"decrypt_error");
554 strcpy(
name,
"unknown_key_id");
558 strcpy(
name,
"disabled_key_id");
562 strcpy(
name,
"key_exchange_disabled");
566 strcpy(
name,
"session_not_ready");
570 strcpy(
name,
"unknown_parameter_index");
574 strcpy(
name,
"duplicate_finished_received");
578 strcpy(
name,
"export_restriction");
582 strcpy(
name,
"protocol_version");
586 strcpy(
name,
"insufficient_security");
590 strcpy(
name,
"internal_error");
594 strcpy(
name,
"user_canceled");
598 strcpy(
name,
"no_renegotiation");
607 strcpy(
name,
"Change Cipher");
611 strcpy(
name,
"Alert");
615 strcpy(
name,
"Handshake");
619 strcpy(
name,
"Application");
628 strcpy(
name,
"Hello Request");
632 strcpy(
name,
"Client Hello");
636 strcpy(
name,
"Server Hello");
640 strcpy(
name,
"Certificate");
644 strcpy(
name,
"Server Key Exchange");
648 strcpy(
name,
"Certificate Request");
652 strcpy(
name,
"Server Hello Done");
656 strcpy(
name,
"Certificate Vaerify");
660 strcpy(
name,
"Client Key Exchange");
664 strcpy(
name,
"Finished");
685 a = wtls_hmac_hash(secret, aPrev,
SHA_80);
688 hashTemp = wtls_hmac_hash(secret, aPlusSeed,
SHA_80);
695 }
while (
octstr_len(hashedData) < byteLength);
712 returnOctstr = wtls_P_hash(secret, labelPlusSeed, byteLength,
719 return (returnOctstr);
725 static unsigned char final_mac[1024];
726 unsigned char *mac, *buffer, *keyString;
727 int bufferlen, keylen;
729 Octstr *returnOctstr = NULL;
746 HMAC(EVP_sha1(), keyString, keylen, buffer, bufferlen, mac,
751 error(0,
"wtls_hmac_hash: SHA_XOR_40 Mac not supported");
759 HMAC(EVP_md5(), keyString, keylen, buffer, bufferlen, mac,
764 return (returnOctstr);
773 int outputDataLength;
774 unsigned char *outputDataTemp;
775 unsigned char *inputDataTemp;
776 unsigned char *tempPointer = NULL;
780 outputDataLength = hash_table[wtls_machine->mac_algorithm].
key_size;
781 inputDataTemp = gw_malloc(inputDataLength);
782 outputDataTemp = gw_malloc(outputDataLength);
786 memcpy((
void *)inputDataTemp, (
void *)tempPointer, inputDataLength);
791 switch (wtls_machine->mac_algorithm) {
800 SHA1(inputDataTemp, inputDataLength, outputDataTemp);
810 tempPointer = MD5(inputDataTemp, inputDataLength,
815 if (wtls_machine->mac_algorithm !=
SHA_0)
816 error(0,
"wtls_hash: Failed to hash input");
817 gw_free(outputDataTemp);
818 gw_free(inputDataTemp);
828 hash_table[wtls_machine->mac_algorithm].mac_size);
831 gw_free(outputDataTemp);
832 gw_free(inputDataTemp);
841 unsigned char *output, iv[20], c[2];
842 des_key_schedule des_ks;
843 des_cblock des_key, des_iv;
848 if (crypt == DES_ENCRYPT) {
851 c[0] = (wtls_machine->server_seq_num & 0xFF00) >> 8;
852 c[1] = wtls_machine->server_seq_num & 0xFF;
855 bulk_table[wtls_machine->bulk_cipher_algorithm].
iv_size;
857 iv[i] = iv[i] ^ c[i % 2];
858 memcpy(des_iv, iv,
sizeof(des_iv));
865 c[0] = (wtls_machine->client_seq_num & 0xFF00) >> 8;
866 c[1] = wtls_machine->client_seq_num & 0xFF;
869 bulk_table[wtls_machine->bulk_cipher_algorithm].
iv_size;
871 iv[i] = iv[i] ^ c[i % 2];
872 memcpy(des_iv, iv,
sizeof(des_iv));
877 des_set_odd_parity(&des_key);
878 if (des_set_key_checked(&des_key, des_ks)) {
879 error(0,
"wtls_des ~> Unable to set key schedule");
882 output = (
unsigned char *)gw_malloc((len + 1) *
sizeof(
unsigned char));
884 des_ks, &des_iv, crypt);
895 unsigned char ebuf[20], *output, *input, iv[20], c[2];
900 EVP_CipherInit(&ectx,
ALG, NULL, NULL, crypt);
901 switch (wtls_machine->bulk_cipher_algorithm) {
911 EVP_CIPHER_CTX_ctrl(&ectx, EVP_CTRL_SET_RC5_ROUNDS, i, NULL);
912 if (crypt == RC5_ENCRYPT) {
915 c[0] = (wtls_machine->server_seq_num & 0xFF00) >> 8;
916 c[1] = wtls_machine->server_seq_num & 0xFF;
917 for (i = 0; i < bulk_table[wtls_machine->bulk_cipher_algorithm].
919 iv[i] = iv[i] ^ c[i % 2];
921 wtls_machine->server_write_enc_key), iv, RC5_ENCRYPT);
925 c[0] = (wtls_machine->client_seq_num & 0xFF00) >> 8;
926 c[1] = wtls_machine->client_seq_num & 0xFF;
927 for (i = 0; i < bulk_table[wtls_machine->bulk_cipher_algorithm].
929 iv[i] = iv[i] ^ c[i % 2];
931 wtls_machine->client_write_enc_key), iv, RC5_DECRYPT);
934 output = gw_malloc(len + 1);
938 for (i = 0; i <= len - 8; i += 8) {
939 EVP_Cipher(&ectx, ebuf, input + i, 8);
940 memmove(output + i, ebuf, 8);
945 EVP_Cipher(&ectx, ebuf, input + i, len - i);
946 memmove(output + i, ebuf, len - i);
956 int numBytesWritten = 0, numBytesToRead = 0;
957 Octstr *decryptedData = NULL;
958 unsigned char *tempDecryptionBuffer = NULL, *tempEncryptionPointer =
962 tempDecryptionBuffer = gw_malloc(RSA_size(private_key));
970 tempEncryptionPointer = (
unsigned char *)
octstr_get_cstr(encryptedData);
973 debug(
"wtls", 0,
"RSA_private_decrypt: Private_key: 0x%p", private_key);
974 numBytesWritten = RSA_private_decrypt(numBytesToRead,
975 tempEncryptionPointer,
976 tempDecryptionBuffer, private_key,
979 if (numBytesWritten == -1) {
980 tempEncryptionPointer += 2;
982 numBytesWritten = RSA_private_decrypt(numBytesToRead,
983 tempEncryptionPointer,
984 tempDecryptionBuffer,
989 if (numBytesWritten > 0) {
994 debug(
"wtls", 0,
"Client's secret decrypted succesfully");
998 gw_free(tempDecryptionBuffer);
1000 return decryptedData;
1008 return (wtls_decrypt_rsa(encryptedData));
1019 Octstr *decryptedData = NULL;
1023 for (i = 0; i < listlen; i++) {
1025 wtls_machine->client_seq_num++;
1028 debug(
"wtls", 0,
"Decrypting PDU %d", i);
1029 if ((decryptedData =
1043 debug(
"wtls", 0,
"PDU %d is not encrypted.", i);
1045 wtls_machine->client_seq_num = -1;
1046 debug(
"wtls", 0,
"Received Incoming Payload:");
1053 RSA *rsaStructure = NULL;
1054 EVP_PKEY *publicKey = NULL;
1055 BIGNUM *modulus = 0, *exponent = NULL;
1056 unsigned char *tempModulusStorage = 0, *tempExponentStorage = NULL;
1059 Octstr *Modulus = NULL, *Exponent = NULL;
1063 publicKey = X509_PUBKEY_get(x509_cert->cert_info->key);
1066 if (EVP_PKEY_type(publicKey->type) != EVP_PKEY_RSA) {
1069 rsaStructure = publicKey->pkey.rsa;
1073 exponent = rsaStructure->e;
1076 numbytes = BN_num_bytes(exponent);
1077 tempExponentStorage = gw_malloc(numbytes);
1080 numbytes = BN_bn2bin(exponent, tempExponentStorage);
1087 modulus = rsaStructure->n;
1090 numbytes = BN_num_bytes(modulus);
1091 tempModulusStorage = gw_malloc(numbytes);
1094 numbytes = BN_bn2bin(modulus, tempModulusStorage);
1105 gw_free(tempModulusStorage);
1106 gw_free(tempExponentStorage);
1108 return (returnStructure);
1111 Octstr *wtls_get_certificate(
void)
1114 unsigned char *ppStart;
1115 int amountWritten = 1260;
1118 debug(
"wtls_get_certificate", 0,
"x509_cert : 0x%p", x509_cert);
1120 amountWritten = i2d_X509(x509_cert, NULL);
1121 debug(
"wtls_get_certificate", 0,
"amountWritten : %d", amountWritten);
1124 pp = (
unsigned char **)gw_malloc(
sizeof(
unsigned char **));
1129 (
unsigned char *)gw_malloc(
sizeof(
unsigned char) * amountWritten);
1130 debug(
"wtls_get_certificate", 0,
"x509_cert_DER_pre : 0x%p", *pp);
1132 amountWritten = i2d_X509(x509_cert, pp);
1136 debug(
"wtls_get_certificate", 0,
"x509_cert_DER_post : 0x%p", *pp);
1148 return returnOctstr;
1161 for (; i < listLen; i++) {
1174 char cipher[20], mac[15];
1180 "wtls_choose_ciphersuite ~> Accepted cipher: %s, mac: %s (#%d/%d)",
1181 cipher, mac, i + 1, listLen);
1192 int isSupportedKeyEx(
int keyExId)
1195 int i = 0, retCode = 0;
1199 for (; i < maxSupported; i++) {
1200 if (keyExId == supportedKeyExSuite[i]) {
1216 for (; i < listLen; i++) {
1227 "wtls_choose_clientkeyid ~> Accepted key algorithm: %s (#%d/%d)",
1228 key, returnKey, listLen);
1244 unsigned char bytes[13], *p;
1247 randomData = gw_malloc(
sizeof(
Random));
1248 gettimeofday(&tp, NULL);
1249 randomData->gmt_unix_time = tp.tv_sec;
1251 while (p - bytes < 12) {
1252 while (!(*p = rand_r((uint *) & tp.tv_usec))) ;
1258 return (randomData);
1267 List * last_received_packet)
1278 List * last_received_packet)
1284 List * last_received_packet)
1314 for (i = 0; i < len; i++) {
1332 for (i = 0; i < len; i++) {
1350 for (i = 0; i < listlen; i++) {
1358 error(0,
"Received critical alert (%s) in %s. Aborting",
1359 alert, stateName(wtls_machine->state));
1373 for (i = 0; i < listlen; i++) {
1382 stateName(wtls_machine->state));
1391 void add_all_handshake_data(
WTLSMachine * wtls_machine,
List * pdu_list)
1399 debug(
"wtls", 0,
"adding handshake data from %ld PDU(s)", listlen);
1400 for (i = 0; i < listlen; i++) {
1406 debug(
"wtls", 0,
"Data from PDU %ld:", i);
1414 Octstr *concatenatedRandoms = NULL;
1415 Octstr *labelMaster = NULL;
1417 int seqNum, refresh;
1419 refresh = 1 << wtls_machine->key_refresh;
1422 seqNum = wtls_machine->server_seq_num;
1423 seqNum -= wtls_machine->server_seq_num % refresh;
1425 octstr_append(concatenatedRandoms, wtls_machine->server_random);
1426 octstr_append(concatenatedRandoms, wtls_machine->client_random);
1431 concatenatedRandoms,
1432 hash_table[wtls_machine->mac_algorithm].
1434 bulk_table[wtls_machine->
1435 bulk_cipher_algorithm].
1437 bulk_table[wtls_machine->
1438 bulk_cipher_algorithm].
1439 iv_size, wtls_machine);
1446 wtls_machine->server_write_MAC_secret =
1448 hash_table[wtls_machine->mac_algorithm].key_size);
1450 hash_table[wtls_machine->mac_algorithm].key_size);
1451 wtls_machine->server_write_enc_key =
1453 bulk_table[wtls_machine->bulk_cipher_algorithm].
1456 bulk_table[wtls_machine->bulk_cipher_algorithm].
1458 wtls_machine->server_write_IV =
1460 bulk_table[wtls_machine->bulk_cipher_algorithm].
1465 if (bulk_table[wtls_machine->bulk_cipher_algorithm].is_exportable ==
1467 Octstr *final_server_write_enc_key = NULL;
1468 Octstr *final_server_write_IV = NULL;
1469 Octstr *emptySecret = NULL;
1471 concatenatedRandoms =
1473 wtls_machine->server_random);
1475 final_server_write_enc_key =
1477 labelMaster, concatenatedRandoms,
1478 bulk_table[wtls_machine->
1479 bulk_cipher_algorithm].
1480 expanded_key_material, wtls_machine);
1483 wtls_machine->server_write_enc_key = final_server_write_enc_key;
1484 final_server_write_enc_key = NULL;
1488 octstr_append(concatenatedRandoms, wtls_machine->client_random);
1489 octstr_append(concatenatedRandoms, wtls_machine->server_random);
1493 final_server_write_IV =
1495 concatenatedRandoms,
1496 bulk_table[wtls_machine->
1497 bulk_cipher_algorithm].
1498 iv_size, wtls_machine);
1500 wtls_machine->server_write_IV = final_server_write_IV;
1509 Octstr *concatenatedRandoms = NULL;
1511 Octstr *labelMaster = NULL;
1512 int seqNum, refresh;
1514 refresh = 1 << wtls_machine->key_refresh;
1517 seqNum = wtls_machine->client_seq_num;
1518 seqNum -= wtls_machine->client_seq_num % refresh;
1519 wtls_machine->last_refresh = seqNum;
1521 octstr_append(concatenatedRandoms, wtls_machine->server_random);
1522 octstr_append(concatenatedRandoms, wtls_machine->client_random);
1527 concatenatedRandoms,
1528 hash_table[wtls_machine->mac_algorithm].
1531 [wtls_machine->bulk_cipher_algorithm].
1533 bulk_table[wtls_machine->
1534 bulk_cipher_algorithm].
1535 iv_size, wtls_machine);
1542 wtls_machine->client_write_MAC_secret =
octstr_copy(key_block, 0,
1548 hash_table[wtls_machine->mac_algorithm].key_size);
1549 wtls_machine->client_write_enc_key =
1551 bulk_table[wtls_machine->bulk_cipher_algorithm].
1554 bulk_table[wtls_machine->bulk_cipher_algorithm].
1556 wtls_machine->client_write_IV =
1558 bulk_table[wtls_machine->bulk_cipher_algorithm].
1563 if (bulk_table[wtls_machine->bulk_cipher_algorithm].is_exportable ==
1565 Octstr *final_client_write_enc_key = NULL;
1566 Octstr *final_client_write_IV = NULL;
1567 Octstr *emptySecret = NULL;
1569 concatenatedRandoms =
octstr_cat(wtls_machine->client_random,
1570 wtls_machine->server_random);
1572 final_client_write_enc_key =
1574 labelMaster, concatenatedRandoms,
1576 [wtls_machine->bulk_cipher_algorithm].
1577 expanded_key_material, wtls_machine);
1581 wtls_machine->client_write_enc_key = final_client_write_enc_key;
1582 final_client_write_enc_key = NULL;
1587 octstr_append(concatenatedRandoms, wtls_machine->client_random);
1588 octstr_append(concatenatedRandoms, wtls_machine->server_random);
1592 final_client_write_IV =
1594 concatenatedRandoms,
1596 [wtls_machine->bulk_cipher_algorithm].
1597 iv_size, wtls_machine);
1599 wtls_machine->client_write_IV = final_client_write_IV;
1600 final_client_write_IV = NULL;
void calculate_client_key_block(WTLSMachine *wtls_machine)
void error(int err, const char *fmt,...)
OPEN NULL_STATE NULL_STATE OPENING packet_is_application_data(event->u.T_Unitdata_Ind.pdu_list)
void calculate_server_key_block(WTLSMachine *wtls_machine)
void octstr_append_data(Octstr *ostr, const char *data, long len)
CipherSuite * wtls_choose_ciphersuite(List *ciphersuites)
enum pubkey_algo PublicKeyAlgorithm
void wtls_payload_destroy(wtls_Payload *payload)
gw_assert(wtls_machine->packet_to_send !=NULL)
void hsName(char *name, int handshake)
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
int wtls_choose_clientkeyid(List *clientKeyIDs, int *algo)
void dump_key_exchange_id(char *dbg, int level, KeyExchangeId *keyexid)
long gwlist_len(List *list)
void wtls_payload_dump(wtls_Payload *msg, int level)
void * gwlist_get(List *list, long pos)
void octstr_append_char(Octstr *ostr, int ch)
int certificates_are_identical(List *pdu_list, List *last_received_packet)
void alertName(char *name, int alert)
Octstr * wtls_decrypt_key(int type, Octstr *encryptedData)
Octstr * wtls_hash(Octstr *inputData, WTLSMachine *wtls_machine)
int changecipherspecs_are_identical(List *pdu_list, List *last_received_packet)
enum keyex_suite KeyExchangeSuite
void pduName(char *name, int pdu)
EXCHANGE NULL_STATE EXCHANGE is_critical_alert(event->u.T_Unitdata_Ind.pdu_list, wtls_machine)
int pack_int16(Octstr *data, long charpos, int i)
#define octstr_get_cstr(ostr)
#define octstr_copy(ostr, from, len)
int is_warning_alert(List *pdu_list, WTLSMachine *wtls_machine)
int packet_contains_userdata(List *pdu_list)
void octstr_insert(Octstr *ostr1, const Octstr *ostr2, long pos)
int wtls_choose_snmode(int snmode)
int packet_contains_optional_stuff(List *pdu_list)
void gwlist_delete(List *list, long pos, long count)
void cipherName(char *name, int cipher)
void octstr_delete(Octstr *ostr1, long pos, long len)
Random * wtls_get_random(void)
Octstr * wtls_decrypt(wtls_Payload *payload, WTLSMachine *wtls_machine)
int packet_contains_finished(List *pdu_list)
#define octstr_duplicate(ostr)
#define octstr_dump(ostr, level,...)
void warning(int err, const char *fmt,...)
RSAPublicKey * wtls_get_rsapublickey(void)
int certifcateverifys_are_identical(List *pdu_list, List *last_received_packet)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
enum sig_algo SignatureAlgorithm
EXCHANGE NULL_STATE clienthellos_are_identical(event->u.T_Unitdata_Ind.pdu_list, wtls_machine->last_received_packet)
long octstr_len(const Octstr *ostr)
void keyName(char *name, int key)
OPEN NULL_STATE NULL_STATE OPENING OPEN NULL_STATE NULL_STATE OPEN packet_contains_clienthello(event->u.T_Unitdata_Ind.pdu_list)
void debug(const char *place, int err, const char *fmt,...)
void wtls_decrypt_pdu_list(WTLSMachine *wtls_machine, List *pdu_list)
int finishes_are_indentical(List *pdu_list, List *last_received_packet)
Octstr * octstr_cat(Octstr *ostr1, Octstr *ostr2)
Octstr * wtls_calculate_prf(Octstr *secret, Octstr *label, Octstr *seed, int byteLength, WTLSMachine *wtls_machine)
void octstr_truncate(Octstr *ostr, int new_len)
Octstr * wtls_encrypt(Octstr *buffer, WTLSMachine *wtls_machine, int recordType)
EXCHANGE NULL_STATE EXCHANGE NULL_STATE OPENING COMMIT packet_contains_changecipherspec(event->u.T_Unitdata_Ind.pdu_list) &&packet_contains_finished(event -> u.T_Unitdata_Ind.pdu_list) &&packet_contains_userdata(event->u.T_Unitdata_Ind.pdu_list),
int octstr_get_char(const Octstr *ostr, long pos)
#define octstr_create_from_data(data, len)
int clientkeyexchanges_are_identical(List *pdu_list, List *last_received_packet)
void macName(char *name, int mac)