Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parameterized SipHash #2216

Closed
wants to merge 1 commit into from

Conversation

tmshort
Copy link
Contributor

@tmshort tmshort commented Jan 11, 2017

The core SipHash supports either 8 or 16-byte output and a configurable
number of rounds.
The default behavior, as added to EVP, is to use 16-byte output and
2,4 rounds, which matches the behavior of most implementations.

Note that documentation has not been updated, as there was some doc updates
for Poly1305 that I did in PR #2128 that I want to build upon.

Checklist
  • documentation is added or updated
  • tests are added or updated
  • CLA is signed
Description of change

@tmshort
Copy link
Contributor Author

tmshort commented Jan 11, 2017

So, this PR basically assumes that PR #2128 will be submitted first.

test/testutil.c Outdated
for (i = 0; i < len; i++)
fprintf(stderr, "%02x", a[i]);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could really be a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah; I pulled it out of poly1305_internal_test.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at BIO_hex_string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaning up all "hexdump" to use that one common routine is a separate PR, but let's not make it the situation worse with this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary with BIO_hex_string, but I undid the changes to poly1305.

@levitte
Copy link
Member

levitte commented Jan 24, 2017

This needs a rebase

@tmshort
Copy link
Contributor Author

tmshort commented Jan 24, 2017

Yup, with the Poly1305 commit.

@tmshort
Copy link
Contributor Author

tmshort commented Jan 24, 2017

Rebased.

@levitte
Copy link
Member

levitte commented Jan 24, 2017

Looks good to me.

Copy link
Contributor

@richsalz richsalz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a few nits. Do we need a no-siphash config option, and what should the default be? I could go either way...

const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len)
{
ASN1_OCTET_STRING *os = NULL;
if (pkey->type != EVP_PKEY_SIPHASH) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line after decl.

#define SIPHASH_MIN_DIGEST_SIZE 8
#define SIPHASH_MAX_DIGEST_SIZE 16

typedef struct siphash_context SIPHASH;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have consistency here, but maybe siphash_st is the more commonly used style?

static void siphash_key_free(EVP_PKEY *pkey)
{
ASN1_OCTET_STRING *os = EVP_PKEY_get0(pkey);
if (os != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line after decls.


static int siphash_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
{
/* nothing, (including ASN1_PKEY_CTRL_DEFAULT_MD_NID), is supported */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, the, first, comma.
or (remove the parens)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three commas in a row? oh my,


/* SIPHASH pkey context structure */

typedef struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a name here, siphash_pkey_ctx_st

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhmmmm... why is that important?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not important.

@@ -49,7 +49,7 @@ The control command is indicated in B<cmd> and any additional arguments in
B<p1> and B<p2>.

For B<cmd> = B<EVP_PKEY_CTRL_SET_MAC_KEY>, B<p1> is the length of the MAC key,
and B<p2> is MAC key. This is used by Poly1305, HMAC and CMAC.
and B<p2> is MAC key. This is used by Poly1305, SipHash, HMAC and CMAC.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all that work and this is the only doc update needed? :) the joy of standard API's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe the EVP_PKEY_SIPHASH (or other similar ones) have a place for documentation. But I should check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was a comment on how good standard API's are. not asking for more work on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I know! :) But I want to be thorough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing referencing stuff like EVP_PKEY_HMAC, etc.

INSTALL Outdated
rc2, rc4, rmd160, scrypt, seed or whirlpool. The "ripemd"
algorithm is deprecated and if used is synonymous with rmd160.
rc2, rc4, rmd160, scrypt, seed, siphash or whirlpool. The
"ripemd" algorithm is deprecated and if used is synonymous
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be some white-space issues here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check space/TAB issues. GH sometimes gets confused, too.

@tmshort
Copy link
Contributor Author

tmshort commented Jan 31, 2017

There already is a no-siphash option. It's currently on by default

The core SipHash supports either 8 or 16-byte output and a configurable
number of rounds.
The default behavior, as added to EVP, is to use 16-byte output and
2,4 rounds, which matches the behavior of most implementations.
There is an EVP_PKEY_CTRL that can control the output size.
@tmshort
Copy link
Contributor Author

tmshort commented Feb 1, 2017

Rebased, comments resolved.

@richsalz
Copy link
Contributor

richsalz commented Feb 1, 2017

@levitte please reconfirm and i will merge.

Copy link
Member

@levitte levitte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconfirming

levitte pushed a commit that referenced this pull request Feb 1, 2017
The core SipHash supports either 8 or 16-byte output and a configurable
number of rounds.
The default behavior, as added to EVP, is to use 16-byte output and
2,4 rounds, which matches the behavior of most implementations.
There is an EVP_PKEY_CTRL that can control the output size.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from #2216)
@richsalz
Copy link
Contributor

richsalz commented Feb 1, 2017

3f5616d on master. Thanks!

@richsalz richsalz closed this Feb 1, 2017
@tmshort tmshort deleted the tshort-siphash branch April 28, 2017 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants