Mercurial > dropbear
comparison common-kex.c @ 1733:d529a52b2f7c coverity coverity
merge coverity from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 26 Jun 2020 21:07:34 +0800 |
parents | 8f93f37c01de |
children | 7d8462677355 |
comparison
equal
deleted
inserted
replaced
1643:b59623a64678 | 1733:d529a52b2f7c |
---|---|
34 #include "packet.h" | 34 #include "packet.h" |
35 #include "bignum.h" | 35 #include "bignum.h" |
36 #include "dbrandom.h" | 36 #include "dbrandom.h" |
37 #include "runopts.h" | 37 #include "runopts.h" |
38 #include "ecc.h" | 38 #include "ecc.h" |
39 #include "curve25519.h" | |
39 #include "crypto_desc.h" | 40 #include "crypto_desc.h" |
40 | 41 |
41 static void kexinitialise(void); | 42 static void kexinitialise(void); |
42 static void gen_new_keys(void); | 43 static void gen_new_keys(void); |
43 #ifndef DISABLE_ZLIB | 44 #ifndef DISABLE_ZLIB |
62 | 63 |
63 /* kex algos */ | 64 /* kex algos */ |
64 buf_put_algolist(ses.writepayload, sshkex); | 65 buf_put_algolist(ses.writepayload, sshkex); |
65 | 66 |
66 /* server_host_key_algorithms */ | 67 /* server_host_key_algorithms */ |
67 buf_put_algolist(ses.writepayload, sshhostkey); | 68 buf_put_algolist(ses.writepayload, sigalgs); |
68 | 69 |
69 /* encryption_algorithms_client_to_server */ | 70 /* encryption_algorithms_client_to_server */ |
70 buf_put_algolist(ses.writepayload, sshciphers); | 71 buf_put_algolist(ses.writepayload, sshciphers); |
71 | 72 |
72 /* encryption_algorithms_server_to_client */ | 73 /* encryption_algorithms_server_to_client */ |
107 ses.kexstate.sentkexinit = 1; | 108 ses.kexstate.sentkexinit = 1; |
108 | 109 |
109 ses.newkeys = (struct key_context*)m_malloc(sizeof(struct key_context)); | 110 ses.newkeys = (struct key_context*)m_malloc(sizeof(struct key_context)); |
110 | 111 |
111 if (ses.send_kex_first_guess) { | 112 if (ses.send_kex_first_guess) { |
112 ses.newkeys->algo_kex = sshkex[0].data; | 113 ses.newkeys->algo_kex = first_usable_algo(sshkex)->data; |
113 ses.newkeys->algo_hostkey = sshhostkey[0].val; | 114 ses.newkeys->algo_signature = first_usable_algo(sigalgs)->val; |
115 ses.newkeys->algo_hostkey = signkey_type_from_signature(ses.newkeys->algo_signature); | |
114 ses.send_kex_first_guess(); | 116 ses.send_kex_first_guess(); |
115 } | 117 } |
116 | 118 |
117 TRACE(("DATAALLOWED=0")) | 119 TRACE(("DATAALLOWED=0")) |
118 TRACE(("-> KEXINIT")) | 120 TRACE(("-> KEXINIT")) |
149 if (ses.kexstate.sentnewkeys && ses.kexstate.recvnewkeys) | 151 if (ses.kexstate.sentnewkeys && ses.kexstate.recvnewkeys) |
150 { | 152 { |
151 TRACE(("switch_keys done")) | 153 TRACE(("switch_keys done")) |
152 ses.keys->algo_kex = ses.newkeys->algo_kex; | 154 ses.keys->algo_kex = ses.newkeys->algo_kex; |
153 ses.keys->algo_hostkey = ses.newkeys->algo_hostkey; | 155 ses.keys->algo_hostkey = ses.newkeys->algo_hostkey; |
156 ses.keys->algo_signature = ses.newkeys->algo_signature; | |
154 ses.keys->allow_compress = 0; | 157 ses.keys->allow_compress = 0; |
155 m_free(ses.newkeys); | 158 m_free(ses.newkeys); |
156 ses.newkeys = NULL; | 159 ses.newkeys = NULL; |
157 kexinitialise(); | 160 kexinitialise(); |
158 } | 161 } |
170 encrypt_packet(); | 173 encrypt_packet(); |
171 | 174 |
172 | 175 |
173 /* set up our state */ | 176 /* set up our state */ |
174 ses.kexstate.sentnewkeys = 1; | 177 ses.kexstate.sentnewkeys = 1; |
178 if (ses.kexstate.donefirstkex) { | |
179 ses.kexstate.donesecondkex = 1; | |
180 } | |
175 ses.kexstate.donefirstkex = 1; | 181 ses.kexstate.donefirstkex = 1; |
176 ses.dataallowed = 1; /* we can send other packets again now */ | 182 ses.dataallowed = 1; /* we can send other packets again now */ |
177 gen_new_keys(); | 183 gen_new_keys(); |
178 switch_keys(); | 184 switch_keys(); |
179 | 185 |
192 } | 198 } |
193 | 199 |
194 | 200 |
195 /* Set up the kex for the first time */ | 201 /* Set up the kex for the first time */ |
196 void kexfirstinitialise() { | 202 void kexfirstinitialise() { |
197 ses.kexstate.donefirstkex = 0; | |
198 | |
199 #ifdef DISABLE_ZLIB | 203 #ifdef DISABLE_ZLIB |
200 ses.compress_algos = ssh_nocompress; | 204 ses.compress_algos = ssh_nocompress; |
201 #else | 205 #else |
202 switch (opts.compress_mode) | 206 switch (opts.compress_mode) |
203 { | 207 { |
326 hashkeys(S2C_IV, sizeof(S2C_IV), &hs, 'B'); | 330 hashkeys(S2C_IV, sizeof(S2C_IV), &hs, 'B'); |
327 hashkeys(C2S_key, sizeof(C2S_key), &hs, 'C'); | 331 hashkeys(C2S_key, sizeof(C2S_key), &hs, 'C'); |
328 hashkeys(S2C_key, sizeof(S2C_key), &hs, 'D'); | 332 hashkeys(S2C_key, sizeof(S2C_key), &hs, 'D'); |
329 | 333 |
330 if (ses.newkeys->recv.algo_crypt->cipherdesc != NULL) { | 334 if (ses.newkeys->recv.algo_crypt->cipherdesc != NULL) { |
331 int recv_cipher = find_cipher(ses.newkeys->recv.algo_crypt->cipherdesc->name); | 335 int recv_cipher = -1; |
332 if (recv_cipher < 0) | 336 if (ses.newkeys->recv.algo_crypt->cipherdesc->name != NULL) { |
333 dropbear_exit("Crypto error"); | 337 recv_cipher = find_cipher(ses.newkeys->recv.algo_crypt->cipherdesc->name); |
338 if (recv_cipher < 0) { | |
339 dropbear_exit("Crypto error"); | |
340 } | |
341 } | |
334 if (ses.newkeys->recv.crypt_mode->start(recv_cipher, | 342 if (ses.newkeys->recv.crypt_mode->start(recv_cipher, |
335 recv_IV, recv_key, | 343 recv_IV, recv_key, |
336 ses.newkeys->recv.algo_crypt->keysize, 0, | 344 ses.newkeys->recv.algo_crypt->keysize, 0, |
337 &ses.newkeys->recv.cipher_state) != CRYPT_OK) { | 345 &ses.newkeys->recv.cipher_state) != CRYPT_OK) { |
338 dropbear_exit("Crypto error"); | 346 dropbear_exit("Crypto error"); |
339 } | 347 } |
340 } | 348 } |
341 | 349 |
342 if (ses.newkeys->trans.algo_crypt->cipherdesc != NULL) { | 350 if (ses.newkeys->trans.algo_crypt->cipherdesc != NULL) { |
343 int trans_cipher = find_cipher(ses.newkeys->trans.algo_crypt->cipherdesc->name); | 351 int trans_cipher = -1; |
344 if (trans_cipher < 0) | 352 if (ses.newkeys->trans.algo_crypt->cipherdesc->name != NULL) { |
345 dropbear_exit("Crypto error"); | 353 trans_cipher = find_cipher(ses.newkeys->trans.algo_crypt->cipherdesc->name); |
354 if (trans_cipher < 0) { | |
355 dropbear_exit("Crypto error"); | |
356 } | |
357 } | |
346 if (ses.newkeys->trans.crypt_mode->start(trans_cipher, | 358 if (ses.newkeys->trans.crypt_mode->start(trans_cipher, |
347 trans_IV, trans_key, | 359 trans_IV, trans_key, |
348 ses.newkeys->trans.algo_crypt->keysize, 0, | 360 ses.newkeys->trans.algo_crypt->keysize, 0, |
349 &ses.newkeys->trans.cipher_state) != CRYPT_OK) { | 361 &ses.newkeys->trans.cipher_state) != CRYPT_OK) { |
350 dropbear_exit("Crypto error"); | 362 dropbear_exit("Crypto error"); |
534 ses.kexstate.recvkexinit = 1; | 546 ses.kexstate.recvkexinit = 1; |
535 | 547 |
536 TRACE(("leave recv_msg_kexinit")) | 548 TRACE(("leave recv_msg_kexinit")) |
537 } | 549 } |
538 | 550 |
551 #if DROPBEAR_NORMAL_DH | |
539 static void load_dh_p(mp_int * dh_p) | 552 static void load_dh_p(mp_int * dh_p) |
540 { | 553 { |
541 bytes_to_mp(dh_p, ses.newkeys->algo_kex->dh_p_bytes, | 554 bytes_to_mp(dh_p, ses.newkeys->algo_kex->dh_p_bytes, |
542 ses.newkeys->algo_kex->dh_p_len); | 555 ses.newkeys->algo_kex->dh_p_len); |
543 } | 556 } |
558 m_mp_init_multi(¶m->pub, ¶m->priv, &dh_g, &dh_p, &dh_q, NULL); | 571 m_mp_init_multi(¶m->pub, ¶m->priv, &dh_g, &dh_p, &dh_q, NULL); |
559 | 572 |
560 /* read the prime and generator*/ | 573 /* read the prime and generator*/ |
561 load_dh_p(&dh_p); | 574 load_dh_p(&dh_p); |
562 | 575 |
563 if (mp_set_int(&dh_g, DH_G_VAL) != MP_OKAY) { | 576 mp_set_ul(&dh_g, DH_G_VAL); |
564 dropbear_exit("Diffie-Hellman error"); | |
565 } | |
566 | 577 |
567 /* calculate q = (p-1)/2 */ | 578 /* calculate q = (p-1)/2 */ |
568 /* dh_priv is just a temp var here */ | 579 /* dh_priv is just a temp var here */ |
569 if (mp_sub_d(&dh_p, 1, ¶m->priv) != MP_OKAY) { | 580 if (mp_sub_d(&dh_p, 1, ¶m->priv) != MP_OKAY) { |
570 dropbear_exit("Diffie-Hellman error"); | 581 dropbear_exit("Diffie-Hellman error"); |
644 buf_putmpint(ses.kexhashbuf, ses.dh_K); | 655 buf_putmpint(ses.kexhashbuf, ses.dh_K); |
645 | 656 |
646 /* calculate the hash H to sign */ | 657 /* calculate the hash H to sign */ |
647 finish_kexhashbuf(); | 658 finish_kexhashbuf(); |
648 } | 659 } |
660 #endif | |
649 | 661 |
650 #if DROPBEAR_ECDH | 662 #if DROPBEAR_ECDH |
651 struct kex_ecdh_param *gen_kexecdh_param() { | 663 struct kex_ecdh_param *gen_kexecdh_param() { |
652 struct kex_ecdh_param *param = m_malloc(sizeof(*param)); | 664 struct kex_ecdh_param *param = m_malloc(sizeof(*param)); |
653 if (ecc_make_key_ex(NULL, dropbear_ltc_prng, | 665 if (ecc_make_key_ex(NULL, dropbear_ltc_prng, |
701 finish_kexhashbuf(); | 713 finish_kexhashbuf(); |
702 } | 714 } |
703 #endif /* DROPBEAR_ECDH */ | 715 #endif /* DROPBEAR_ECDH */ |
704 | 716 |
705 #if DROPBEAR_CURVE25519 | 717 #if DROPBEAR_CURVE25519 |
706 struct kex_curve25519_param *gen_kexcurve25519_param () { | 718 struct kex_curve25519_param *gen_kexcurve25519_param() { |
707 /* Per http://cr.yp.to/ecdh.html */ | 719 /* Per http://cr.yp.to/ecdh.html */ |
708 struct kex_curve25519_param *param = m_malloc(sizeof(*param)); | 720 struct kex_curve25519_param *param = m_malloc(sizeof(*param)); |
709 const unsigned char basepoint[32] = {9}; | 721 const unsigned char basepoint[32] = {9}; |
710 | 722 |
711 genrandom(param->priv, CURVE25519_LEN); | 723 genrandom(param->priv, CURVE25519_LEN); |
712 param->priv[0] &= 248; | 724 dropbear_curve25519_scalarmult(param->pub, param->priv, basepoint); |
713 param->priv[31] &= 127; | |
714 param->priv[31] |= 64; | |
715 | |
716 curve25519_donna(param->pub, param->priv, basepoint); | |
717 | 725 |
718 return param; | 726 return param; |
719 } | 727 } |
720 | 728 |
721 void free_kexcurve25519_param(struct kex_curve25519_param *param) | 729 void free_kexcurve25519_param(struct kex_curve25519_param *param) { |
722 { | |
723 m_burn(param->priv, CURVE25519_LEN); | 730 m_burn(param->priv, CURVE25519_LEN); |
724 m_free(param); | 731 m_free(param); |
725 } | 732 } |
726 | 733 |
727 void kexcurve25519_comb_key(const struct kex_curve25519_param *param, const buffer *buf_pub_them, | 734 void kexcurve25519_comb_key(const struct kex_curve25519_param *param, const buffer *buf_pub_them, |
734 if (buf_pub_them->len != CURVE25519_LEN) | 741 if (buf_pub_them->len != CURVE25519_LEN) |
735 { | 742 { |
736 dropbear_exit("Bad curve25519"); | 743 dropbear_exit("Bad curve25519"); |
737 } | 744 } |
738 | 745 |
739 curve25519_donna(out, param->priv, buf_pub_them->data); | 746 dropbear_curve25519_scalarmult(out, param->priv, buf_pub_them->data); |
740 | 747 |
741 if (constant_time_memcmp(zeroes, out, CURVE25519_LEN) == 0) { | 748 if (constant_time_memcmp(zeroes, out, CURVE25519_LEN) == 0) { |
742 dropbear_exit("Bad curve25519"); | 749 dropbear_exit("Bad curve25519"); |
743 } | 750 } |
744 | 751 |
820 char * erralgo = NULL; | 827 char * erralgo = NULL; |
821 | 828 |
822 int goodguess = 0; | 829 int goodguess = 0; |
823 int allgood = 1; /* we AND this with each goodguess and see if its still | 830 int allgood = 1; /* we AND this with each goodguess and see if its still |
824 true after */ | 831 true after */ |
825 | 832 int kexguess2 = 0; |
833 | |
834 buf_incrpos(ses.payload, 16); /* start after the cookie */ | |
835 | |
836 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys)); | |
837 | |
838 /* kex_algorithms */ | |
826 #if DROPBEAR_KEXGUESS2 | 839 #if DROPBEAR_KEXGUESS2 |
827 enum kexguess2_used kexguess2 = KEXGUESS2_LOOK; | 840 if (buf_has_algo(ses.payload, KEXGUESS2_ALGO_NAME) == DROPBEAR_SUCCESS) { |
828 #else | 841 kexguess2 = 1; |
829 enum kexguess2_used kexguess2 = KEXGUESS2_NO; | 842 } |
830 #endif | 843 #endif |
831 | 844 |
832 buf_incrpos(ses.payload, 16); /* start after the cookie */ | 845 #if DROPBEAR_EXT_INFO |
833 | 846 /* Determine if SSH_MSG_EXT_INFO messages should be sent. |
834 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys)); | 847 Should be done for the first key exchange. Only required on server side |
835 | 848 for server-sig-algs */ |
836 /* kex_algorithms */ | 849 if (IS_DROPBEAR_SERVER) { |
837 algo = buf_match_algo(ses.payload, sshkex, &kexguess2, &goodguess); | 850 if (!ses.kexstate.donefirstkex) { |
851 if (buf_has_algo(ses.payload, SSH_EXT_INFO_C) == DROPBEAR_SUCCESS) { | |
852 ses.allow_ext_info = 1; | |
853 } | |
854 } | |
855 } | |
856 #endif | |
857 | |
858 algo = buf_match_algo(ses.payload, sshkex, kexguess2, &goodguess); | |
838 allgood &= goodguess; | 859 allgood &= goodguess; |
839 if (algo == NULL || algo->val == KEXGUESS2_ALGO_ID) { | 860 if (algo == NULL || algo->data == NULL) { |
861 /* kexguess2, ext-info-c, ext-info-s should not match negotiation */ | |
840 erralgo = "kex"; | 862 erralgo = "kex"; |
841 goto error; | 863 goto error; |
842 } | 864 } |
843 TRACE(("kexguess2 %d", kexguess2)) | 865 TRACE(("kexguess2 %d", kexguess2)) |
844 TRACE(("kex algo %s", algo->name)) | 866 TRACE(("kex algo %s", algo->name)) |
845 ses.newkeys->algo_kex = algo->data; | 867 ses.newkeys->algo_kex = algo->data; |
846 | 868 |
847 /* server_host_key_algorithms */ | 869 /* server_host_key_algorithms */ |
848 algo = buf_match_algo(ses.payload, sshhostkey, &kexguess2, &goodguess); | 870 algo = buf_match_algo(ses.payload, sigalgs, kexguess2, &goodguess); |
849 allgood &= goodguess; | 871 allgood &= goodguess; |
850 if (algo == NULL) { | 872 if (algo == NULL) { |
851 erralgo = "hostkey"; | 873 erralgo = "hostkey"; |
852 goto error; | 874 goto error; |
853 } | 875 } |
854 TRACE(("hostkey algo %s", algo->name)) | 876 TRACE(("signature algo %s", algo->name)) |
855 ses.newkeys->algo_hostkey = algo->val; | 877 ses.newkeys->algo_signature = algo->val; |
878 ses.newkeys->algo_hostkey = signkey_type_from_signature(ses.newkeys->algo_signature); | |
856 | 879 |
857 /* encryption_algorithms_client_to_server */ | 880 /* encryption_algorithms_client_to_server */ |
858 c2s_cipher_algo = buf_match_algo(ses.payload, sshciphers, NULL, NULL); | 881 c2s_cipher_algo = buf_match_algo(ses.payload, sshciphers, 0, NULL); |
859 if (c2s_cipher_algo == NULL) { | 882 if (c2s_cipher_algo == NULL) { |
860 erralgo = "enc c->s"; | 883 erralgo = "enc c->s"; |
861 goto error; | 884 goto error; |
862 } | 885 } |
863 TRACE(("enc c2s is %s", c2s_cipher_algo->name)) | 886 TRACE(("enc c2s is %s", c2s_cipher_algo->name)) |
864 | 887 |
865 /* encryption_algorithms_server_to_client */ | 888 /* encryption_algorithms_server_to_client */ |
866 s2c_cipher_algo = buf_match_algo(ses.payload, sshciphers, NULL, NULL); | 889 s2c_cipher_algo = buf_match_algo(ses.payload, sshciphers, 0, NULL); |
867 if (s2c_cipher_algo == NULL) { | 890 if (s2c_cipher_algo == NULL) { |
868 erralgo = "enc s->c"; | 891 erralgo = "enc s->c"; |
869 goto error; | 892 goto error; |
870 } | 893 } |
871 TRACE(("enc s2c is %s", s2c_cipher_algo->name)) | 894 TRACE(("enc s2c is %s", s2c_cipher_algo->name)) |
872 | 895 |
873 /* mac_algorithms_client_to_server */ | 896 /* mac_algorithms_client_to_server */ |
874 c2s_hash_algo = buf_match_algo(ses.payload, sshhashes, NULL, NULL); | 897 c2s_hash_algo = buf_match_algo(ses.payload, sshhashes, 0, NULL); |
898 #if DROPBEAR_AEAD_MODE | |
899 if (((struct dropbear_cipher_mode*)c2s_cipher_algo->mode)->aead_crypt != NULL) { | |
900 c2s_hash_algo = NULL; | |
901 } else | |
902 #endif | |
875 if (c2s_hash_algo == NULL) { | 903 if (c2s_hash_algo == NULL) { |
876 erralgo = "mac c->s"; | 904 erralgo = "mac c->s"; |
877 goto error; | 905 goto error; |
878 } | 906 } |
879 TRACE(("hash c2s is %s", c2s_hash_algo->name)) | 907 TRACE(("hash c2s is %s", c2s_hash_algo ? c2s_hash_algo->name : "<implicit>")) |
880 | 908 |
881 /* mac_algorithms_server_to_client */ | 909 /* mac_algorithms_server_to_client */ |
882 s2c_hash_algo = buf_match_algo(ses.payload, sshhashes, NULL, NULL); | 910 s2c_hash_algo = buf_match_algo(ses.payload, sshhashes, 0, NULL); |
911 #if DROPBEAR_AEAD_MODE | |
912 if (((struct dropbear_cipher_mode*)s2c_cipher_algo->mode)->aead_crypt != NULL) { | |
913 s2c_hash_algo = NULL; | |
914 } else | |
915 #endif | |
883 if (s2c_hash_algo == NULL) { | 916 if (s2c_hash_algo == NULL) { |
884 erralgo = "mac s->c"; | 917 erralgo = "mac s->c"; |
885 goto error; | 918 goto error; |
886 } | 919 } |
887 TRACE(("hash s2c is %s", s2c_hash_algo->name)) | 920 TRACE(("hash s2c is %s", s2c_hash_algo ? s2c_hash_algo->name : "<implicit>")) |
888 | 921 |
889 /* compression_algorithms_client_to_server */ | 922 /* compression_algorithms_client_to_server */ |
890 c2s_comp_algo = buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL); | 923 c2s_comp_algo = buf_match_algo(ses.payload, ses.compress_algos, 0, NULL); |
891 if (c2s_comp_algo == NULL) { | 924 if (c2s_comp_algo == NULL) { |
892 erralgo = "comp c->s"; | 925 erralgo = "comp c->s"; |
893 goto error; | 926 goto error; |
894 } | 927 } |
895 TRACE(("hash c2s is %s", c2s_comp_algo->name)) | 928 TRACE(("hash c2s is %s", c2s_comp_algo->name)) |
896 | 929 |
897 /* compression_algorithms_server_to_client */ | 930 /* compression_algorithms_server_to_client */ |
898 s2c_comp_algo = buf_match_algo(ses.payload, ses.compress_algos, NULL, NULL); | 931 s2c_comp_algo = buf_match_algo(ses.payload, ses.compress_algos, 0, NULL); |
899 if (s2c_comp_algo == NULL) { | 932 if (s2c_comp_algo == NULL) { |
900 erralgo = "comp s->c"; | 933 erralgo = "comp s->c"; |
901 goto error; | 934 goto error; |
902 } | 935 } |
903 TRACE(("hash s2c is %s", s2c_comp_algo->name)) | 936 TRACE(("hash s2c is %s", s2c_comp_algo->name)) |
927 ses.newkeys->recv.crypt_mode = | 960 ses.newkeys->recv.crypt_mode = |
928 (struct dropbear_cipher_mode*)s2c_cipher_algo->mode; | 961 (struct dropbear_cipher_mode*)s2c_cipher_algo->mode; |
929 ses.newkeys->trans.crypt_mode = | 962 ses.newkeys->trans.crypt_mode = |
930 (struct dropbear_cipher_mode*)c2s_cipher_algo->mode; | 963 (struct dropbear_cipher_mode*)c2s_cipher_algo->mode; |
931 ses.newkeys->recv.algo_mac = | 964 ses.newkeys->recv.algo_mac = |
965 #if DROPBEAR_AEAD_MODE | |
966 s2c_hash_algo == NULL ? ses.newkeys->recv.crypt_mode->aead_mac : | |
967 #endif | |
932 (struct dropbear_hash*)s2c_hash_algo->data; | 968 (struct dropbear_hash*)s2c_hash_algo->data; |
933 ses.newkeys->trans.algo_mac = | 969 ses.newkeys->trans.algo_mac = |
970 #if DROPBEAR_AEAD_MODE | |
971 c2s_hash_algo == NULL ? ses.newkeys->trans.crypt_mode->aead_mac : | |
972 #endif | |
934 (struct dropbear_hash*)c2s_hash_algo->data; | 973 (struct dropbear_hash*)c2s_hash_algo->data; |
935 ses.newkeys->recv.algo_comp = s2c_comp_algo->val; | 974 ses.newkeys->recv.algo_comp = s2c_comp_algo->val; |
936 ses.newkeys->trans.algo_comp = c2s_comp_algo->val; | 975 ses.newkeys->trans.algo_comp = c2s_comp_algo->val; |
937 } else { | 976 } else { |
938 /* SERVER */ | 977 /* SERVER */ |
943 ses.newkeys->recv.crypt_mode = | 982 ses.newkeys->recv.crypt_mode = |
944 (struct dropbear_cipher_mode*)c2s_cipher_algo->mode; | 983 (struct dropbear_cipher_mode*)c2s_cipher_algo->mode; |
945 ses.newkeys->trans.crypt_mode = | 984 ses.newkeys->trans.crypt_mode = |
946 (struct dropbear_cipher_mode*)s2c_cipher_algo->mode; | 985 (struct dropbear_cipher_mode*)s2c_cipher_algo->mode; |
947 ses.newkeys->recv.algo_mac = | 986 ses.newkeys->recv.algo_mac = |
987 #if DROPBEAR_AEAD_MODE | |
988 c2s_hash_algo == NULL ? ses.newkeys->recv.crypt_mode->aead_mac : | |
989 #endif | |
948 (struct dropbear_hash*)c2s_hash_algo->data; | 990 (struct dropbear_hash*)c2s_hash_algo->data; |
949 ses.newkeys->trans.algo_mac = | 991 ses.newkeys->trans.algo_mac = |
992 #if DROPBEAR_AEAD_MODE | |
993 s2c_hash_algo == NULL ? ses.newkeys->trans.crypt_mode->aead_mac : | |
994 #endif | |
950 (struct dropbear_hash*)s2c_hash_algo->data; | 995 (struct dropbear_hash*)s2c_hash_algo->data; |
951 ses.newkeys->recv.algo_comp = c2s_comp_algo->val; | 996 ses.newkeys->recv.algo_comp = c2s_comp_algo->val; |
952 ses.newkeys->trans.algo_comp = s2c_comp_algo->val; | 997 ses.newkeys->trans.algo_comp = s2c_comp_algo->val; |
953 } | 998 } |
954 | 999 |