Skip to content

Commit b1b0ad1

Browse files
committed
deprecate AEAD::set_ad()
1 parent 1a82edd commit b1b0ad1

6 files changed

Lines changed: 21 additions & 20 deletions

File tree

src/cli/cipher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Cipher final : public Command
6262
#if defined(BOTAN_HAS_AEAD_MODES)
6363
if(Botan::AEAD_Mode* aead = dynamic_cast<Botan::AEAD_Mode*>(cipher.get()))
6464
{
65-
aead->set_ad(ad);
65+
aead->set_associated_data(ad);
6666
}
6767
else
6868
#endif

src/cli/timing_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ ticks Lucky13_Timing_Test::measure_critical_function(const std::vector<uint8_t>&
242242
Botan::secure_vector<uint8_t> key(16 + m_mac_keylen);
243243

244244
m_dec.set_key(unlock(key));
245-
m_dec.set_ad(unlock(aad));
245+
m_dec.set_associated_data(aad);
246246
m_dec.start(unlock(iv));
247247

248248
ticks start = get_ticks();

src/lib/modes/aead/aead.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class BOTAN_PUBLIC_API(2,0) AEAD_Mode : public Cipher_Mode
124124
*
125125
* @param ad the associated data
126126
*/
127+
BOTAN_DEPRECATED("Please use set_associated_data")
127128
void set_ad(std::span<const uint8_t> ad)
128129
{
129130
set_associated_data(ad);

src/lib/tls/tls12/tls_record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void write_record(secure_vector<uint8_t>& output,
237237

238238
const size_t rec_size = ctext_size + cs.nonce_bytes_from_record();
239239

240-
aead.set_ad(aad);
240+
aead.set_associated_data(aad);
241241

242242
const std::vector<uint8_t> nonce = cs.aead_nonce(record_sequence, rng);
243243

src/tests/test_aead.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class AEAD_Tests final : public Text_Based_Test
7272
[&]() { enc->finish(garbage); });
7373
}
7474

75-
enc->set_ad(mutate_vec(ad));
75+
enc->set_associated_data(mutate_vec(ad));
7676
enc->start(mutate_vec(nonce));
7777
enc->update(garbage);
7878

@@ -87,13 +87,13 @@ class AEAD_Tests final : public Text_Based_Test
8787

8888
try
8989
{
90-
enc->set_ad(ad);
90+
enc->set_associated_data(ad);
9191
}
9292
catch(Botan::Invalid_State&)
9393
{
9494
// ad after setting nonce rejected, in this case we need to reset
9595
enc->reset();
96-
enc->set_ad(ad);
96+
enc->set_associated_data(ad);
9797
enc->start(nonce);
9898
}
9999

@@ -118,7 +118,7 @@ class AEAD_Tests final : public Text_Based_Test
118118
// reset state first
119119
enc->reset();
120120

121-
enc->set_ad(ad);
121+
enc->set_associated_data(ad);
122122
enc->start(nonce);
123123

124124
buf.assign(input.begin(), input.end());
@@ -152,7 +152,7 @@ class AEAD_Tests final : public Text_Based_Test
152152
// again reset state first
153153
enc->reset();
154154

155-
enc->set_ad(ad);
155+
enc->set_associated_data(ad);
156156
enc->start(nonce);
157157

158158
buf.assign(input.begin(), input.end());
@@ -184,7 +184,7 @@ class AEAD_Tests final : public Text_Based_Test
184184
}
185185

186186
// Make sure we can set the AD after processing a message
187-
enc->set_ad(ad);
187+
enc->set_associated_data(ad);
188188
enc->clear();
189189
result.test_eq("key is not set", enc->has_keying_material(), false);
190190

@@ -237,7 +237,7 @@ class AEAD_Tests final : public Text_Based_Test
237237
result.test_eq("key is not set", dec->has_keying_material(), false);
238238
dec->set_key(key);
239239
result.test_eq("key is set", dec->has_keying_material(), true);
240-
dec->set_ad(mutate_vec(ad));
240+
dec->set_associated_data(mutate_vec(ad));
241241

242242
if(is_siv == false)
243243
{
@@ -262,13 +262,13 @@ class AEAD_Tests final : public Text_Based_Test
262262
try
263263
{
264264
dec->start(nonce);
265-
dec->set_ad(ad);
265+
dec->set_associated_data(ad);
266266
}
267267
catch(Botan::Invalid_State&)
268268
{
269269
// ad after setting nonce rejected, in this case we need to reset
270270
dec->reset();
271-
dec->set_ad(ad);
271+
dec->set_associated_data(ad);
272272
dec->start(nonce);
273273
}
274274

@@ -283,7 +283,7 @@ class AEAD_Tests final : public Text_Based_Test
283283
// reset state first
284284
dec->reset();
285285

286-
dec->set_ad(ad);
286+
dec->set_associated_data(ad);
287287
dec->start(nonce);
288288

289289
buf.assign(input.begin(), input.end());
@@ -317,7 +317,7 @@ class AEAD_Tests final : public Text_Based_Test
317317
// again reset state first
318318
dec->reset();
319319

320-
dec->set_ad(ad);
320+
dec->set_associated_data(ad);
321321
dec->start(nonce);
322322

323323
buf.assign(input.begin(), input.end());
@@ -359,7 +359,7 @@ class AEAD_Tests final : public Text_Based_Test
359359

360360
dec->reset();
361361

362-
dec->set_ad(ad);
362+
dec->set_associated_data(ad);
363363
dec->start(nonce);
364364

365365
try
@@ -383,7 +383,7 @@ class AEAD_Tests final : public Text_Based_Test
383383
std::vector<uint8_t> bad_nonce = mutate_vec(nonce);
384384

385385
dec->reset();
386-
dec->set_ad(ad);
386+
dec->set_associated_data(ad);
387387
dec->start(bad_nonce);
388388

389389
try
@@ -405,7 +405,7 @@ class AEAD_Tests final : public Text_Based_Test
405405
const std::vector<uint8_t> bad_ad = mutate_vec(ad, true);
406406

407407
dec->reset();
408-
dec->set_ad(bad_ad);
408+
dec->set_associated_data(bad_ad);
409409

410410
dec->start(nonce);
411411

@@ -425,7 +425,7 @@ class AEAD_Tests final : public Text_Based_Test
425425
}
426426

427427
// Make sure we can set the AD after processing a message
428-
dec->set_ad(ad);
428+
dec->set_associated_data(ad);
429429
dec->clear();
430430
result.test_eq("key is not set", dec->has_keying_material(), false);
431431

src/tests/test_ocb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ class OCB_Wide_KAT_Tests final : public Text_Based_Test
138138
Botan::OCB_Encryption enc(std::make_unique<OCB_Wide_Test_Block_Cipher>(bs),
139139
std::min<size_t>(bs, 32));
140140
enc.set_key(key);
141-
enc.set_ad(ad);
141+
enc.set_associated_data(ad);
142142
enc.start(nonce);
143143
enc.finish(buf);
144144
result.test_eq("Ciphertext matches", buf, expected);
145145

146146
Botan::OCB_Decryption dec(std::make_unique<OCB_Wide_Test_Block_Cipher>(bs),
147147
std::min<size_t>(bs, 32));
148148
dec.set_key(key);
149-
dec.set_ad(ad);
149+
dec.set_associated_data(ad);
150150
dec.start(nonce);
151151
dec.finish(buf);
152152
result.test_eq("Decryption correct", buf, input);

0 commit comments

Comments
 (0)