Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-RAN
Commits
70765d1e
Commit
70765d1e
authored
Feb 24, 2023
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/old-openssl' into integration_2023_w08b
parents
f35945e9
a4eeefc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
openair3/SECU/sha_256_hmac.c
openair3/SECU/sha_256_hmac.c
+31
-4
No files found.
openair3/SECU/sha_256_hmac.c
View file @
70765d1e
...
...
@@ -24,8 +24,9 @@
#include <openssl/hmac.h>
#if OPENSSL_VERSION_MAJOR >= 3
// code for version 3.0 or greater
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
/* code for version 3.0 or greater */
#include <openssl/core_names.h>
...
...
@@ -72,8 +73,11 @@ void sha_256_hmac(const uint8_t key[32], byte_array_t data, size_t len, uint8_t
EVP_MAC_free
(
mac
);
OSSL_LIB_CTX_free
(
library_context
);
}
#else
// code for 1.1.x or lower
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
/* code for version >= 1.1.0 and < 3.0.0 */
void
sha_256_hmac
(
const
uint8_t
key
[
32
],
byte_array_t
data
,
size_t
len
,
uint8_t
out
[
len
])
{
DevAssert
(
key
!=
NULL
);
...
...
@@ -92,4 +96,27 @@ void sha_256_hmac(const uint8_t key[32], byte_array_t data, size_t len, uint8_t
HMAC_CTX_free
(
ctx
);
}
#else
/* code for version lower than 1.1.0 */
void
sha_256_hmac
(
const
uint8_t
key
[
32
],
byte_array_t
data
,
size_t
len
,
uint8_t
out
[
len
])
{
DevAssert
(
key
!=
NULL
);
DevAssert
(
data
.
buf
!=
NULL
);
DevAssert
(
data
.
len
!=
0
);
DevAssert
(
len
!=
0
);
HMAC_CTX
ctx
;
HMAC_CTX_init
(
&
ctx
);
HMAC_Init_ex
(
&
ctx
,
key
,
32
,
EVP_sha256
(),
NULL
);
HMAC_Update
(
&
ctx
,
data
.
buf
,
data
.
len
);
HMAC_Final
(
&
ctx
,
out
,
(
uint32_t
*
)
&
len
);
HMAC_CTX_cleanup
(
&
ctx
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment