Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openairinterface5G
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mingxuan Li
openairinterface5G
Commits
a4eeefc1
Commit
a4eeefc1
authored
2 years ago
by
Cédric Roux
Browse files
Options
Downloads
Patches
Plain Diff
support old versions of openssl
Needed for ubuntu 16 and centos 7.
parent
646cec27
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openair3/SECU/sha_256_hmac.c
+31
-4
31 additions, 4 deletions
openair3/SECU/sha_256_hmac.c
with
31 additions
and
4 deletions
openair3/SECU/sha_256_hmac.c
+
31
−
4
View file @
a4eeefc1
...
@@ -24,8 +24,9 @@
...
@@ -24,8 +24,9 @@
#include
<openssl/hmac.h>
#include
<openssl/hmac.h>
#if OPENSSL_VERSION_MAJOR >= 3
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
// code for version 3.0 or greater
/* code for version 3.0 or greater */
#include
<openssl/core_names.h>
#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
...
@@ -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
);
EVP_MAC_free
(
mac
);
OSSL_LIB_CTX_free
(
library_context
);
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
])
void
sha_256_hmac
(
const
uint8_t
key
[
32
],
byte_array_t
data
,
size_t
len
,
uint8_t
out
[
len
])
{
{
DevAssert
(
key
!=
NULL
);
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
...
@@ -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
);
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
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment