Parameters/gcryctl to digest algorithms?
Werner Koch
wk at gnupg.org
Mon Mar 24 10:31:20 CET 2014
On Sun, 23 Mar 2014 21:18, dbaryshkov at gmail.com said:
> digest calculation. I can add another algo for that s-box, however I fear
> that it would be an overkill. I was also thinking about reusing
Please use a new algorithm number. In case you expect that you need
several of them in the uture, it is probably useful to reserve a range
of algorithm ids like:
GCRY_MD_GOSTR3411_94 = 308, /* GOST R 34.11-94. */
GCRY_MD_STRIBOG256 = 309, /* GOST R 34.11-2012, 256 bit. */
GCRY_MD_STRIBOG512 = 310 /* GOST R 34.11-2012, 512 bit. */
GCRY_MD_GOSTR3411_XX = 401 /* 402 to 4xx reserved for other variants. */
> flags part of md_open() call, but also couldn't come up with a good
> enough solution.
Flags require lots of special cases, ranges of algorithm ids can be
implemented in a generalized way:
typedef struct gcry_md_spec
{
int algo; /* Actually used algo. */
+ int first_algo; /* Modules supports algo range starting here ... */
+ int last_algo; /* .. up to here. */
struct {
unsigned int disabled:1;
unsigned int fips:1;
} flags;
...
}
static gcry_md_spec_t *
spec_from_algo (int algo)
{
int idx;
gcry_md_spec_t *spec;
algo = map_algo (algo);
for (idx = 0; (spec = digest_list[idx]); idx++)
- if (algo == spec->algo)
+ if (algo >= spec->first_algo && algo <= spec->last_algo)
return spec;
return NULL;
}
then it is up to the digest module to do whatever it needs to do.
Salam-Shalom,
Werner
--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
More information about the Gcrypt-devel
mailing list