Skip to content

Commit

Permalink
tests: Replace custom bit with more generic flags
Browse files Browse the repository at this point in the history
* tests/basic.c (global): New flag FLAG_SPECIAL
  (check_pubkey_crypt): Change to use bitfield flags

--

Applied the master commit of:
	299e2f9

GnuPG-bug-id: 5918
Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje authored and NIIBE Yutaka committed May 6, 2022
1 parent d8a13d9 commit 9c55ba3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ typedef struct test_spec_pubkey
}
test_spec_pubkey_t;

#define FLAG_CRYPT (1 << 0)
#define FLAG_SIGN (1 << 1)
#define FLAG_GRIP (1 << 2)
#define FLAG_NOFIPS (1 << 3)
#define FLAG_CFB8 (1 << 4)
#define FLAG_CRYPT (1 << 0)
#define FLAG_SIGN (1 << 1)
#define FLAG_GRIP (1 << 2)
#define FLAG_NOFIPS (1 << 3)
#define FLAG_CFB8 (1 << 4)
#define FLAG_SPECIAL (1 << 5)

static int in_fips_mode;

Expand Down Expand Up @@ -15558,7 +15559,7 @@ check_pubkey_crypt (int n, gcry_sexp_t skey, gcry_sexp_t pkey, int algo,
int unpadded;
int encrypt_expected_rc;
int decrypt_expected_rc;
int special;
int flags;
} datas[] =
{
{ GCRY_PK_RSA,
Expand Down Expand Up @@ -15642,14 +15643,14 @@ check_pubkey_crypt (int n, gcry_sexp_t skey, gcry_sexp_t pkey, int algo,
"(flags oaep)",
1,
0,
GPG_ERR_ENCODING_PROBLEM, 1 },
GPG_ERR_ENCODING_PROBLEM, FLAG_SPECIAL },
{ GCRY_PK_RSA,
"(data\n (flags oaep)\n"
" (value #11223344556677889900AA#))\n",
"(flags pkcs1)",
1,
0,
GPG_ERR_ENCODING_PROBLEM, 1 },
GPG_ERR_ENCODING_PROBLEM, FLAG_SPECIAL },
{ 0,
"(data\n (flags pss)\n"
" (value #11223344556677889900AA#))\n",
Expand Down Expand Up @@ -15725,7 +15726,7 @@ check_pubkey_crypt (int n, gcry_sexp_t skey, gcry_sexp_t pkey, int algo,
ciph = list;
}
rc = gcry_pk_decrypt (&plain, ciph, skey);
if (!rc && datas[dataidx].special == 1)
if (!rc && (datas[dataidx].flags & FLAG_SPECIAL))
{
/* It may happen that OAEP formatted data which is
decrypted as pkcs#1 data returns a valid pkcs#1
Expand Down

0 comments on commit 9c55ba3

Please sign in to comment.