@@ -1069,8 +1069,12 @@ init_encrypted_dst(pgp_write_handler_t *handler, pgp_dest_t *dst, pgp_dest_t *wr
1069
1069
bool singlepass = true ;
1070
1070
unsigned pkeycount = 0 ;
1071
1071
unsigned skeycount = 0 ;
1072
- unsigned keylen;
1073
- rnp_result_t ret = RNP_ERROR_GENERIC;
1072
+ #if defined(ENABLE_CRYPTO_REFRESH)
1073
+ bool use_v6_pkesk = false ;
1074
+ bool use_v6_skesk = false ;
1075
+ #endif
1076
+ unsigned keylen;
1077
+ rnp_result_t ret = RNP_ERROR_GENERIC;
1074
1078
1075
1079
keylen = pgp_key_size (handler->ctx ->ealg );
1076
1080
if (!keylen) {
@@ -1120,16 +1124,15 @@ init_encrypted_dst(pgp_write_handler_t *handler, pgp_dest_t *dst, pgp_dest_t *wr
1120
1124
skeycount = handler->ctx ->passwords .size ();
1121
1125
1122
1126
#if defined(ENABLE_CRYPTO_REFRESH)
1123
- /* in the case of PKESK (pkeycount > 0) and all keys are PKESKv6/SEIPDv2 capable, ugprade
1124
- * to AEADv2 */
1125
- if (handler->ctx ->enable_pkesk_v6 && handler-> ctx -> pkeskv6_capable () && pkeycount > 0 ) {
1126
- param-> auth_type = rnp::AuthType::AEADv2 ;
1127
- }
1127
+ /* We use v6 PKESK/SKESK with v2 SEIPD if all recipients support it
1128
+ and the variables enable_pkesk_v6 and enable_skesk_v6 are set. */
1129
+ if (handler->ctx ->aalg != PGP_AEAD_NONE ) {
1130
+ use_v6_pkesk = handler-> ctx -> enable_pkesk_v6 && handler-> ctx -> pkeskv6_capable () ;
1131
+ use_v6_skesk = handler-> ctx -> enable_skesk_v6 ;
1128
1132
1129
- /* Use SEIPDv2 for SKESK if enabled and preconditions are met */
1130
- if (handler->ctx ->enable_skesk_v6 && handler->ctx ->aalg != PGP_AEAD_NONE &&
1131
- skeycount > 0 ) {
1132
- param->auth_type = rnp::AuthType::AEADv2;
1133
+ if ((use_v6_pkesk || !pkeycount) && (use_v6_skesk || !skeycount)) {
1134
+ param->auth_type = rnp::AuthType::AEADv2;
1135
+ }
1133
1136
}
1134
1137
#endif
1135
1138
param->aalg = handler->ctx ->aalg ;
0 commit comments