Lines Matching refs:mac

70 #include "mac.h"
387 struct sshmac *mac, size_t mac_already, u_int discard)
392 if (enc == NULL || !cipher_is_cbc(enc->cipher) || (mac && mac->etm)) {
398 * Record number of bytes over which the mac has already
401 if (mac && mac->enabled) {
402 state->packet_discard_mac = mac;
933 struct sshmac *mac;
972 mac = &state->newkeys[mode]->mac;
975 if ((r = mac_init(mac)) != 0)
978 mac->enabled = 1;
993 explicit_bzero(mac->key, mac->key_len); */
1136 * Finalize packet in SSH2 format (compress, mac, encrypt, enqueue)
1147 struct sshmac *mac = NULL;
1153 mac = &state->newkeys[MODE_OUT]->mac;
1155 /* disable mac for authenticated encryption */
1157 mac = NULL;
1160 aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0;
1244 if (mac && mac->enabled && !mac->etm) {
1245 if ((r = mac_compute(mac, state->p_send.seqnr,
1260 if (mac && mac->enabled) {
1261 if (mac->etm) {
1262 /* EtM: compute mac over aadlen + cipher text */
1263 if ((r = mac_compute(mac, state->p_send.seqnr,
1269 if ((r = sshbuf_put(state->output, macbuf, mac->mac_len)) != 0)
1540 struct sshmac *mac = NULL;
1554 mac = &state->newkeys[MODE_IN]->mac;
1556 /* disable mac for authenticated encryption */
1558 mac = NULL;
1560 maclen = mac && mac->enabled ? mac->mac_len : 0;
1562 aadlen = (mac && mac->enabled && mac->etm) || authlen ? 4 : 0;
1605 return ssh_packet_start_discard(ssh, enc, mac, 0,
1628 return ssh_packet_start_discard(ssh, enc, mac, 0,
1645 /* EtM: check mac over encrypted input */
1646 if (mac && mac->enabled && mac->etm) {
1647 if ((r = mac_check(mac, state->p_read.seqnr,
1664 if (mac && mac->enabled) {
1666 if (!mac->etm && (r = mac_check(mac, state->p_read.seqnr,
1675 return ssh_packet_start_discard(ssh, enc, mac,
1681 if ((r = sshbuf_consume(state->input, mac->mac_len)) != 0)
2340 struct sshmac *mac;
2347 mac = &newkey->mac;
2362 if ((r = sshbuf_put_cstring(b, mac->name)) != 0 ||
2363 (r = sshbuf_put_u32(b, mac->enabled)) != 0 ||
2364 (r = sshbuf_put_string(b, mac->key, mac->key_len)) != 0)
2410 struct sshmac *mac;
2425 mac = &newkey->mac;
2439 if ((r = sshbuf_get_cstring(b, &mac->name, NULL)) != 0)
2441 if ((r = mac_setup(mac, mac->name)) != 0)
2443 if ((r = sshbuf_get_u32(b, (u_int *)&mac->enabled)) != 0 ||
2444 (r = sshbuf_get_string(b, &mac->key, &maclen)) != 0)
2446 if (maclen > mac->key_len) {
2450 mac->key_len = maclen;