Skip to content

Commit

Permalink
Add and use function pgp_is_aes().
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Dec 20, 2024
1 parent 18add10 commit 299f28a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/lib/crypto/symmetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ typedef struct pgp_crypt_t {
unsigned pgp_block_size(pgp_symm_alg_t);
unsigned pgp_key_size(pgp_symm_alg_t);
bool pgp_is_sa_supported(int alg, bool silent = false);
bool pgp_is_sa_aes(pgp_symm_alg_t alg);
size_t pgp_cipher_block_size(pgp_crypt_t *crypt);

/**
Expand Down
13 changes: 13 additions & 0 deletions src/lib/crypto/symmetric_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ pgp_key_size(pgp_symm_alg_t alg)
}
}

bool
pgp_is_sa_aes(pgp_symm_alg_t alg)
{
switch (alg) {
case PGP_SA_AES_128:
case PGP_SA_AES_192:
case PGP_SA_AES_256:
return true;
default:
return false;
}
}

#if defined(ENABLE_AEAD)
size_t
pgp_cipher_aead_granularity(pgp_crypt_t *crypt)
Expand Down
17 changes: 2 additions & 15 deletions src/librepgp/stream-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,20 +1226,7 @@ do_encrypt_pkesk_v3_alg_id(pgp_pubkey_alg_t alg)
bool
check_enforce_aes_v3_pkesk(pgp_pubkey_alg_t alg, pgp_symm_alg_t salg, pgp_pkesk_version_t ver)
{
if (ver != PGP_PKSK_V3) {
return true;
}
/* The same algorithms */
if (have_pkesk_checksum(alg)) {
return true;
}
switch (salg) {
case PGP_SA_AES_128:
case PGP_SA_AES_192:
case PGP_SA_AES_256:
return true;
default:
return false;
}
/* The same algorithms as with pkesk_checksum */
return (ver != PGP_PKSK_V3) || have_pkesk_checksum(alg) || pgp_is_sa_aes(salg);
}
#endif

0 comments on commit 299f28a

Please sign in to comment.