Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ieee1905
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Multi-AP
ieee1905
Commits
f5905943
Commit
f5905943
authored
2 years ago
by
Anjan Chanda
Browse files
Options
Downloads
Patches
Plain Diff
map: cntlrsync: fix build
parent
3646db99
No related branches found
No related tags found
No related merge requests found
Pipeline
#108471
passed
2 years ago
Stage: static_code_analysis
Stage: compile_test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/extensions/map/cntlrsync.c
+25
-48
25 additions, 48 deletions
src/extensions/map/cntlrsync.c
with
25 additions
and
48 deletions
src/extensions/map/cntlrsync.c
+
25
−
48
View file @
f5905943
...
@@ -26,50 +26,37 @@
...
@@ -26,50 +26,37 @@
int
build_sync_config_request
(
uint8_t
*
aladdr
,
uint8_t
**
m1
,
uint16_t
*
m1_size
,
int
build_sync_config_request
(
uint8_t
*
aladdr
,
uint8_t
**
m1
,
uint16_t
*
m1_size
,
void
**
key
)
void
**
key
)
{
{
struct
wsc_key
*
private_
key
;
struct
wsc_key
*
local
key
;
uint8_t
nonce_e
[
16
];
uint8_t
nonce_e
[
16
];
uint8_t
*
buf
;
uint8_t
*
buf
;
uint8_t
*
p
;
uint8_t
*
p
;
size_t
rem
;
size_t
rem
;
uint8_t
*
priv
,
*
pub
;
uint16_t
priv_len
=
0
,
pub_len
=
0
;
buf
=
calloc
(
1000
,
sizeof
(
uint8_t
));
buf
=
calloc
(
1000
,
sizeof
(
uint8_t
));
if
(
!
buf
)
if
(
!
buf
)
return
-
ENOMEM
;
return
-
ENOMEM
;
localkey
=
calloc
(
1
,
sizeof
(
*
localkey
));
/* generate key-pair */
if
(
!
localkey
)
{
PLATFORM_GENERATE_DH_KEY_PAIR
(
&
priv
,
&
priv_len
,
&
pub
,
&
pub_len
);
fprintf
(
stderr
,
"privlen = %d publen = %d
\n
"
,
priv_len
,
pub_len
);
private_key
=
calloc
(
1
,
sizeof
(
*
private_key
));
if
(
!
private_key
)
{
free
(
buf
);
free
(
buf
);
free
(
priv
);
free
(
pub
);
fprintf
(
stderr
,
"-ENOMEM
\n
"
);
fprintf
(
stderr
,
"-ENOMEM
\n
"
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
private_key
->
key
=
calloc
(
priv_len
,
sizeof
(
uint8_t
));
/* generate key-pair */
if
(
!
private_key
->
key
)
{
if
(
PLATFORM_GENERATE_DH_KEY_PAIR
(
&
localkey
->
key
,
free
(
private_key
);
&
localkey
->
keylen
,
&
localkey
->
pub
,
&
localkey
->
publen
)
!=
0
)
{
free
(
localkey
);
free
(
buf
);
free
(
buf
);
free
(
priv
);
return
-
1
;
free
(
pub
);
fprintf
(
stderr
,
"-ENOMEM
\n
"
);
return
-
ENOMEM
;
}
}
private_key
->
keylen
=
priv_len
;
if
(
priv_len
>
0
)
memcpy
(
private_key
->
key
,
priv
,
priv_len
);
memcpy
(
private_
key
->
macaddr
,
aladdr
,
6
);
memcpy
(
local
key
->
macaddr
,
aladdr
,
6
);
get_random_bytes
(
16
,
nonce_e
);
get_random_bytes
(
16
,
nonce_e
);
memcpy
(
private_
key
->
nonce
,
nonce_e
,
16
);
memcpy
(
local
key
->
nonce
,
nonce_e
,
16
);
p
=
buf
;
p
=
buf
;
rem
=
1000
;
rem
=
1000
;
...
@@ -77,22 +64,17 @@ int build_sync_config_request(uint8_t *aladdr, uint8_t **m1, uint16_t *m1_size,
...
@@ -77,22 +64,17 @@ int build_sync_config_request(uint8_t *aladdr, uint8_t **m1, uint16_t *m1_size,
if
(
wsc_put
(
&
p
,
&
rem
,
ATTR_MAC_ADDR
,
aladdr
,
6
)
||
if
(
wsc_put
(
&
p
,
&
rem
,
ATTR_MAC_ADDR
,
aladdr
,
6
)
||
wsc_put
(
&
p
,
&
rem
,
ATTR_ENROLLEE_NONCE
,
nonce_e
,
16
)
||
wsc_put
(
&
p
,
&
rem
,
ATTR_ENROLLEE_NONCE
,
nonce_e
,
16
)
||
wsc_put
(
&
p
,
&
rem
,
ATTR_PUBLIC_KEY
,
pub
,
pub
_
len
))
{
wsc_put
(
&
p
,
&
rem
,
ATTR_PUBLIC_KEY
,
localkey
->
pub
,
localkey
->
publen
))
{
free
(
private_
key
->
key
);
free
(
local
key
->
key
);
free
(
private_
key
);
free
(
local
key
);
free
(
buf
);
free
(
buf
);
free
(
priv
);
free
(
pub
);
fprintf
(
stderr
,
"Error adding wsc attributes
\n
"
);
fprintf
(
stderr
,
"Error adding wsc attributes
\n
"
);
return
-
1
;
return
-
1
;
}
}
*
m1
=
buf
;
*
m1
=
buf
;
*
m1_size
=
abs
(
p
-
buf
);
*
m1_size
=
labs
(
p
-
buf
);
*
key
=
private_key
;
*
key
=
localkey
;
free
(
pub
);
free
(
priv
);
return
0
;
return
0
;
}
}
...
@@ -116,8 +98,8 @@ int build_sync_config_response(uint8_t *m1, uint16_t m1_size,
...
@@ -116,8 +98,8 @@ int build_sync_config_response(uint8_t *m1, uint16_t m1_size,
uint16_t
local_privkey_len
;
uint16_t
local_privkey_len
;
uint8_t
*
local_privkey
;
uint8_t
*
local_privkey
;
uint16
_t
priv_len
=
0
;
size
_t
priv_len
=
0
;
uint16
_t
pub_len
=
0
;
size
_t
pub_len
=
0
;
uint8_t
nonce_r
[
16
];
uint8_t
nonce_r
[
16
];
uint8_t
*
priv
;
uint8_t
*
priv
;
uint8_t
*
pub
;
uint8_t
*
pub
;
...
@@ -189,14 +171,13 @@ int build_sync_config_response(uint8_t *m1, uint16_t m1_size,
...
@@ -189,14 +171,13 @@ int build_sync_config_response(uint8_t *m1, uint16_t m1_size,
if
(
ret
)
if
(
ret
)
return
-
1
;
return
-
1
;
fprintf
(
stderr
,
"plen|%d|, publen|%d|
\n
"
,
priv_len
,
pub_len
);
local_privkey
=
priv
;
local_privkey
=
priv
;
local_privkey_len
=
priv_len
;
local_privkey_len
=
priv_len
;
{
{
uint8_t
keys
[
WPS_AUTHKEY_LEN
+
WPS_KEYWRAPKEY_LEN
+
WPS_EMSK_LEN
];
uint8_t
keys
[
WPS_AUTHKEY_LEN
+
WPS_KEYWRAPKEY_LEN
+
WPS_EMSK_LEN
];
uint8_t
dhkey
[
SHA256_MAC_LEN
];
uint8_t
dhkey
[
SHA256_MAC_LEN
];
uint8_t
kdk
[
SHA256_MAC_LEN
];
uint8_t
kdk
[
SHA256_MAC_LEN
];
uint16
_t
shared_secret_len
;
size
_t
shared_secret_len
;
uint8_t
*
shared_secret
;
uint8_t
*
shared_secret
;
const
uint8_t
*
addr
[
3
];
const
uint8_t
*
addr
[
3
];
size_t
len
[
3
];
size_t
len
[
3
];
...
@@ -212,7 +193,8 @@ int build_sync_config_response(uint8_t *m1, uint16_t m1_size,
...
@@ -212,7 +193,8 @@ int build_sync_config_response(uint8_t *m1, uint16_t m1_size,
m1_pubkey
,
m1_pubkey
,
m1_pubkey_len
,
m1_pubkey_len
,
local_privkey
,
local_privkey
,
local_privkey_len
);
local_privkey_len
,
pub
,
pub_len
);
if
(
ret
)
if
(
ret
)
goto
out
;
goto
out
;
...
@@ -452,8 +434,6 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
...
@@ -452,8 +434,6 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
uint16_t
m2_encrypted_settings_len
=
0
;
uint16_t
m2_encrypted_settings_len
=
0
;
uint8_t
*
m2_authenticator
=
NULL
;
uint8_t
*
m2_authenticator
=
NULL
;
uint8_t
m2_authenticator_present
=
0
;
uint8_t
m2_authenticator_present
=
0
;
uint8_t
*
m1_privkey
;
uint16_t
m1_privkey_len
;
uint8_t
*
m1_macaddr
;
uint8_t
*
m1_macaddr
;
uint8_t
*
m1_nonce
;
uint8_t
*
m1_nonce
;
...
@@ -479,8 +459,6 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
...
@@ -479,8 +459,6 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
k
=
(
struct
wsc_key
*
)
key
;
k
=
(
struct
wsc_key
*
)
key
;
m1_privkey
=
k
->
key
;
m1_privkey_len
=
k
->
keylen
;
m1_macaddr
=
k
->
macaddr
;
m1_macaddr
=
k
->
macaddr
;
m1_nonce
=
k
->
nonce
;
m1_nonce
=
k
->
nonce
;
...
@@ -549,7 +527,7 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
...
@@ -549,7 +527,7 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
/* derive keys - authkey, keywrapkey and emsk */
/* derive keys - authkey, keywrapkey and emsk */
{
{
uint8_t
*
shared_secret
;
uint8_t
*
shared_secret
;
uint16
_t
shared_secret_len
;
size
_t
shared_secret_len
;
const
uint8_t
*
addr
[
3
];
const
uint8_t
*
addr
[
3
];
size_t
len
[
3
];
size_t
len
[
3
];
uint8_t
dhkey
[
SHA256_MAC_LEN
];
uint8_t
dhkey
[
SHA256_MAC_LEN
];
...
@@ -561,8 +539,8 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
...
@@ -561,8 +539,8 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
&
shared_secret_len
,
&
shared_secret_len
,
m2_pubkey
,
m2_pubkey
,
m2_pubkey_len
,
m2_pubkey_len
,
m1_privkey
,
k
->
key
,
k
->
keylen
,
m1_privkey_
len
);
k
->
pub
,
k
->
pub
len
);
if
(
ret
)
if
(
ret
)
return
-
1
;
return
-
1
;
...
@@ -603,7 +581,6 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
...
@@ -603,7 +581,6 @@ int process_sync_config_response(uint8_t *m1, uint16_t m1_size, void *key,
fprintf
(
stderr
,
"WPS keys:
\n
"
);
fprintf
(
stderr
,
"WPS keys:
\n
"
);
bufprintf
(
m2_pubkey
,
m2_pubkey_len
,
"Registrar public key"
);
bufprintf
(
m2_pubkey
,
m2_pubkey_len
,
"Registrar public key"
);
/* bufprintf(m1_privkey, m1_privkey_len, "Enrollee private key"); */
bufprintf
(
shared_secret
,
shared_secret_len
,
"DH Shared secret"
);
bufprintf
(
shared_secret
,
shared_secret_len
,
"DH Shared secret"
);
//bufprintf(dhkey, 32, "DH Key");
//bufprintf(dhkey, 32, "DH Key");
//bufprintf(m1_nonce, 16, "Nonce-E");
//bufprintf(m1_nonce, 16, "Nonce-E");
...
...
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