Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cbsspeke
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Charles Wright
Cbsspeke
Commits
d6bafa1f
Commit
d6bafa1f
authored
3 years ago
by
Charles Wright
Browse files
Options
Downloads
Patches
Plain Diff
Switch to storing client_id, server_id, and password inside the client/server contexts
parent
eb44a5da
No related branches found
Branches containing commit
Tags
v0.1.3
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bsspeke.c
+37
-11
37 additions, 11 deletions
bsspeke.c
bsspeke.h
+7
-47
7 additions, 47 deletions
bsspeke.h
with
44 additions
and
58 deletions
bsspeke.c
+
37
−
11
View file @
d6bafa1f
...
...
@@ -63,32 +63,58 @@ generate_random_bytes(uint8_t *buf, size_t len)
#endif
}
void
int
bsspeke_client_init
(
bsspeke_client_ctx
*
ctx
,
const
char
*
client_id
,
const
size_t
client_id_len
,
const
char
*
server_id
,
const
size_t
server_id_len
,
const
char
*
password
,
const
size_t
password_len
)
{
ctx
->
client_id
=
(
uint8_t
*
)
client_id
;
const
char
*
password
,
const
size_t
password_len
)
{
if
(
client_id_len
>
255
)
{
return
-
1
;
}
crypto_wipe
(
ctx
->
client_id
,
256
);
memcpy
(
ctx
->
client_id
,
client_id
,
client_id_len
);
ctx
->
client_id_len
=
client_id_len
;
ctx
->
server_id
=
(
uint8_t
*
)
server_id
;
if
(
server_id_len
>
255
)
{
return
-
1
;
}
crypto_wipe
(
ctx
->
server_id
,
256
);
memcpy
(
ctx
->
server_id
,
server_id
,
server_id_len
);
ctx
->
server_id_len
=
server_id_len
;
ctx
->
password
=
(
uint8_t
*
)
password
;
if
(
password_len
>
255
)
{
return
-
1
;
}
crypto_wipe
(
ctx
->
password
,
256
);
memcpy
(
ctx
->
password
,
password
,
password_len
);
ctx
->
password_len
=
password_len
;
// Success!
return
0
;
}
void
int
bsspeke_server_init
(
bsspeke_server_ctx
*
ctx
,
const
char
*
server_id
,
const
size_t
server_id_len
,
const
char
*
client_id
,
const
size_t
client_id_len
)
{
ctx
->
server_id
=
(
uint8_t
*
)
server_id
;
const
char
*
client_id
,
const
size_t
client_id_len
)
{
if
(
server_id_len
>
255
)
{
return
-
1
;
}
crypto_wipe
(
ctx
->
server_id
,
256
);
memcpy
(
ctx
->
server_id
,
server_id
,
server_id_len
);
ctx
->
server_id_len
=
server_id_len
;
ctx
->
client_id
=
(
uint8_t
*
)
client_id
;
if
(
client_id_len
>
255
)
{
return
-
1
;
}
crypto_wipe
(
ctx
->
client_id
,
256
);
memcpy
(
ctx
->
client_id
,
client_id
,
client_id_len
);
ctx
->
client_id_len
=
client_id_len
;
// Success!
return
0
;
}
void
...
...
This diff is collapsed.
Click to expand it.
bsspeke.h
+
7
−
47
View file @
d6bafa1f
...
...
@@ -36,12 +36,12 @@ extern "C" {
typedef
struct
{
// Login credentials
uint8_t
*
client_id
;
uint8_t
client_id
[
256
]
;
size_t
client_id_len
;
uint8_t
*
password
;
uint8_t
password
[
256
]
;
size_t
password_len
;
// Server identifier
uint8_t
*
server_id
;
uint8_t
server_id
[
256
]
;
size_t
server_id_len
;
// Random number to blind the password in the OPRF
uint8_t
r
[
32
];
...
...
@@ -58,10 +58,10 @@ typedef struct {
}
bsspeke_client_ctx
;
typedef
struct
{
uint8_t
*
server_id
;
// Server's identifier (eg domain name)
uint8_t
server_id
[
256
]
;
// Server's identifier (eg domain name)
size_t
server_id_len
;
uint8_t
*
client_id
;
// Client's identifier (eg Matrix user_id)
uint8_t
client_id
[
256
]
;
// Client's identifier (eg Matrix user_id)
size_t
client_id_len
;
//uint8_t P[32]; // Base point for the user
...
...
@@ -76,53 +76,14 @@ typedef struct {
}
bsspeke_server_ctx
;
typedef
struct
{
char
*
client_id
;
uint8_t
blind
[
32
];
}
bsspeke_msg1_t
;
/*
typedef bsspeke_msg1_t bsspeke_setup_msg1_t;
typedef struct {
uint8_t blind_salt[32];
} bsspeke_setup_msg2_t;
typedef struct {
uint8_t P[32];
uint8_t V[32];
uint32_t phf_blocks;
uint32_t phf_iterations;
} bsspeke_setup_msg3_t;
*/
/*
typedef bsspeke_msg1_t bsspeke_login_msg1_t;
typedef struct {
uint8_t blind_salt[32];
uint8_t B[32];
uint32_t phf_blocks;
uint32_t phf_iterations;
} bsspeke_login_msg2_t;
typedef struct {
uint8_t A[32];
uint8_t client_verifier[32];
} bsspeke_login_msg3_t;
typedef struct {
uint8_t server_verifier[32];
} bsspeke_login_msg4_t;
*/
void
int
bsspeke_client_init
(
bsspeke_client_ctx
*
ctx
,
const
char
*
client_id
,
const
size_t
client_id_len
,
const
char
*
server_id
,
const
size_t
server_id_len
,
const
char
*
password
,
const
size_t
password_len
);
void
int
bsspeke_server_init
(
bsspeke_server_ctx
*
ctx
,
const
char
*
server_id
,
const
size_t
server_id_len
,
const
char
*
client_id
,
const
size_t
client_id_len
);
...
...
@@ -131,7 +92,6 @@ void
bsspeke_client_generate_blind
(
uint8_t
blind
[
32
],
bsspeke_client_ctx
*
client
);
void
bsspeke_server_blind_salt
(
uint8_t
blind_salt
[
32
],
const
uint8_t
blind
[
32
],
...
...
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