@@ -1047,6 +1047,10 @@ init_encrypted_dst(pgp_write_handler_t *handler, pgp_dest_t *dst, pgp_dest_t *wr
10471047 bool singlepass = true ;
10481048 unsigned pkeycount = 0 ;
10491049 unsigned skeycount = 0 ;
1050+ #if defined(ENABLE_CRYPTO_REFRESH)
1051+ bool use_v6_pkesk = false ;
1052+ bool use_v6_skesk = false ;
1053+ #endif
10501054 unsigned keylen;
10511055 rnp_result_t ret = RNP_ERROR_GENERIC;
10521056
@@ -1090,16 +1094,15 @@ init_encrypted_dst(pgp_write_handler_t *handler, pgp_dest_t *dst, pgp_dest_t *wr
10901094 skeycount = handler->ctx ->passwords .size ();
10911095
10921096#if defined(ENABLE_CRYPTO_REFRESH)
1093- /* in the case of PKESK (pkeycount > 0) and all keys are PKESKv6/SEIPDv2 capable, ugprade
1094- * to AEADv2 */
1095- if (handler->ctx ->enable_pkesk_v6 && handler-> ctx -> pkeskv6_capable () && pkeycount > 0 ) {
1096- param-> auth_type = rnp::AuthType::AEADv2 ;
1097- }
1097+ /* We use v6 PKESK/SKESK with v2 SEIPD if all recipients support it
1098+ and the variables enable_pkesk_v6 and enable_skesk_v6 are set. */
1099+ if (handler->ctx ->aalg != PGP_AEAD_NONE ) {
1100+ use_v6_pkesk = handler-> ctx -> enable_pkesk_v6 && handler-> ctx -> pkeskv6_capable () ;
1101+ use_v6_skesk = handler-> ctx -> enable_skesk_v6 ;
10981102
1099- /* Use SEIPDv2 for SKESK if enabled and preconditions are met */
1100- if (handler->ctx ->enable_skesk_v6 && handler->ctx ->aalg != PGP_AEAD_NONE &&
1101- skeycount > 0 ) {
1102- param->auth_type = rnp::AuthType::AEADv2;
1103+ if ((use_v6_pkesk || !pkeycount) && (use_v6_skesk || !skeycount) ) {
1104+ param->auth_type = rnp::AuthType::AEADv2;
1105+ }
11031106 }
11041107#endif
11051108 param->aalg = handler->ctx ->aalg ;
0 commit comments