-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from fjmolinas/pr_hkdf
cose: add HKDF (HMAC256)
- Loading branch information
Showing
10 changed files
with
420 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2018 Freie Universitat Berlin | ||
* Copyright (C) 2018 Inria | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
#include "cose/crypto.h" | ||
|
||
bool cose_crypto_is_hkdf(cose_algo_t alg) | ||
{ | ||
/* NOLINTNEXTLINE(hicpp-multiway-paths-covered) */ | ||
switch (alg) { | ||
#ifdef HAVE_ALGO_HMAC256 | ||
case COSE_ALGO_HMAC256: | ||
return true; | ||
#endif | ||
default: | ||
(void)alg; | ||
return false; | ||
} | ||
} | ||
|
||
int cose_crypto_hkdf_derive(const uint8_t *salt, size_t salt_len, | ||
const uint8_t *ikm, size_t ikm_length, | ||
const uint8_t *info, size_t info_length, | ||
uint8_t *out, size_t out_length, | ||
cose_algo_t alg) | ||
{ | ||
/* NOLINTNEXTLINE(hicpp-multiway-paths-covered) */ | ||
switch (alg) { | ||
#ifdef HAVE_ALGO_HMAC256 | ||
case COSE_ALGO_HMAC256: | ||
return cose_crypto_hkdf_derive_sha256(salt, salt_len, ikm, | ||
ikm_length, info, info_length, out, out_length); | ||
#endif | ||
default: | ||
(void)salt; | ||
(void)salt_len; | ||
(void)ikm; | ||
(void)ikm_length; | ||
(void)info; | ||
(void)info_length; | ||
(void)out; | ||
(void)out_length; | ||
(void)alg; | ||
return COSE_ERR_NOTIMPLEMENTED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.