Newer
Older
/*
* bsspeke.h - BS-SPEKE over Curve25519
*
* Author: Charles V. Wright <cvwright@futo.org>
*
* Copyright (c) 2022 FUTO Holdings, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef BSSPEKE_H
#define BSSPEKE_H
#define BSSPEKE_VERIFY_CLIENT_MODIFIER "client"
#define BSSPEKE_VERIFY_CLIENT_MODIFIER_LEN 6
#define BSSPEKE_VERIFY_SERVER_MODIFIER "server"
#define BSSPEKE_VERIFY_SERVER_MODIFIER_LEN 6
#define BSSPEKE_MIN_PHF_BLOCKS 100000
#define BSSPEKE_MIN_PHF_ITERATIONS 3
typedef struct {
// Login credentials
uint8_t *client_id;
size_t client_id_len;
uint8_t *password;
size_t password_len;
// Server identifier
uint8_t *server_id;
size_t server_id_len;
// Random number to blind the password in the OPRF
uint8_t r[32];
// Server's ephemeral public key
uint8_t B[32];
// Ephemeral keypair
uint8_t a[32];
//uint8_t A[32];
// Session key
uint8_t K_c[32];
} bsspeke_client_ctx;
typedef struct {
uint8_t *server_id;
size_t server_id_len;
uint8_t *client_id;
size_t client_id_len;
// Stored ECDH parameters for the given user
//uint8_t P[32]; // Base point
uint8_t V[32]; // User's long-term public key
// Ephemeral keypair
uint8_t b[32];
uint8_t B[32];
// User's ephemeral public key
uint8_t A[32];
// Session key
uint8_t K_s[32];
} bsspeke_server_ctx;
typedef struct {
char *client_id;
uint8_t *blind;
} bsspeke_msg1_t;
typedef struct {
uint8_t blind_salt[32];
uint8_t B[32];
uint32_t phf_blocks;
uint32_t phf_iterations;
} bsspeke_msg2_t;
typedef struct {
uint8_t A[32];
uint8_t client_verifier[32];
} bsspeke_msg3_t;
typedef struct {
uint8_t server_verifier[32];
} bsspeke_msg4_t;
#endif