Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wolfssl/wolfcrypt/srp.h@15:117db924cf7c, 2018-08-18 (annotated)
- Committer:
- wolfSSL
- Date:
- Sat Aug 18 22:20:43 2018 +0000
- Revision:
- 15:117db924cf7c
wolfSSL 3.15.3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 15:117db924cf7c | 1 | /* srp.h |
wolfSSL | 15:117db924cf7c | 2 | * |
wolfSSL | 15:117db924cf7c | 3 | * Copyright (C) 2006-2017 wolfSSL Inc. |
wolfSSL | 15:117db924cf7c | 4 | * |
wolfSSL | 15:117db924cf7c | 5 | * This file is part of wolfSSL. |
wolfSSL | 15:117db924cf7c | 6 | * |
wolfSSL | 15:117db924cf7c | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 15:117db924cf7c | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 15:117db924cf7c | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 15:117db924cf7c | 10 | * (at your option) any later version. |
wolfSSL | 15:117db924cf7c | 11 | * |
wolfSSL | 15:117db924cf7c | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 15:117db924cf7c | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 15:117db924cf7c | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 15:117db924cf7c | 15 | * GNU General Public License for more details. |
wolfSSL | 15:117db924cf7c | 16 | * |
wolfSSL | 15:117db924cf7c | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 15:117db924cf7c | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 15:117db924cf7c | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
wolfSSL | 15:117db924cf7c | 20 | */ |
wolfSSL | 15:117db924cf7c | 21 | |
wolfSSL | 15:117db924cf7c | 22 | /*! |
wolfSSL | 15:117db924cf7c | 23 | \file wolfssl/wolfcrypt/srp.h |
wolfSSL | 15:117db924cf7c | 24 | */ |
wolfSSL | 15:117db924cf7c | 25 | |
wolfSSL | 15:117db924cf7c | 26 | #ifdef WOLFCRYPT_HAVE_SRP |
wolfSSL | 15:117db924cf7c | 27 | |
wolfSSL | 15:117db924cf7c | 28 | #ifndef WOLFCRYPT_SRP_H |
wolfSSL | 15:117db924cf7c | 29 | #define WOLFCRYPT_SRP_H |
wolfSSL | 15:117db924cf7c | 30 | |
wolfSSL | 15:117db924cf7c | 31 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 15:117db924cf7c | 32 | #include <wolfssl/wolfcrypt/sha.h> |
wolfSSL | 15:117db924cf7c | 33 | #include <wolfssl/wolfcrypt/sha256.h> |
wolfSSL | 15:117db924cf7c | 34 | #include <wolfssl/wolfcrypt/sha512.h> |
wolfSSL | 15:117db924cf7c | 35 | #include <wolfssl/wolfcrypt/integer.h> |
wolfSSL | 15:117db924cf7c | 36 | |
wolfSSL | 15:117db924cf7c | 37 | #ifdef __cplusplus |
wolfSSL | 15:117db924cf7c | 38 | extern "C" { |
wolfSSL | 15:117db924cf7c | 39 | #endif |
wolfSSL | 15:117db924cf7c | 40 | |
wolfSSL | 15:117db924cf7c | 41 | /* Select the largest available hash for the buffer size. */ |
wolfSSL | 15:117db924cf7c | 42 | #if defined(WOLFSSL_SHA512) |
wolfSSL | 15:117db924cf7c | 43 | #define SRP_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE |
wolfSSL | 15:117db924cf7c | 44 | #elif defined(WOLFSSL_SHA384) |
wolfSSL | 15:117db924cf7c | 45 | #define SRP_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE |
wolfSSL | 15:117db924cf7c | 46 | #elif !defined(NO_SHA256) |
wolfSSL | 15:117db924cf7c | 47 | #define SRP_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE |
wolfSSL | 15:117db924cf7c | 48 | #elif !defined(NO_SHA) |
wolfSSL | 15:117db924cf7c | 49 | #define SRP_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE |
wolfSSL | 15:117db924cf7c | 50 | #else |
wolfSSL | 15:117db924cf7c | 51 | #error "You have to have some kind of SHA hash if you want to use SRP." |
wolfSSL | 15:117db924cf7c | 52 | #endif |
wolfSSL | 15:117db924cf7c | 53 | |
wolfSSL | 15:117db924cf7c | 54 | /* Set the minimum number of bits acceptable in an SRP modulus */ |
wolfSSL | 15:117db924cf7c | 55 | #define SRP_MODULUS_MIN_BITS 512 |
wolfSSL | 15:117db924cf7c | 56 | |
wolfSSL | 15:117db924cf7c | 57 | /* Set the minimum number of bits acceptable for private keys (RFC 5054) */ |
wolfSSL | 15:117db924cf7c | 58 | #define SRP_PRIVATE_KEY_MIN_BITS 256 |
wolfSSL | 15:117db924cf7c | 59 | |
wolfSSL | 15:117db924cf7c | 60 | /* salt size for SRP password */ |
wolfSSL | 15:117db924cf7c | 61 | #define SRP_SALT_SIZE 16 |
wolfSSL | 15:117db924cf7c | 62 | |
wolfSSL | 15:117db924cf7c | 63 | /** |
wolfSSL | 15:117db924cf7c | 64 | * SRP side, client or server. |
wolfSSL | 15:117db924cf7c | 65 | */ |
wolfSSL | 15:117db924cf7c | 66 | typedef enum { |
wolfSSL | 15:117db924cf7c | 67 | SRP_CLIENT_SIDE = 0, |
wolfSSL | 15:117db924cf7c | 68 | SRP_SERVER_SIDE = 1, |
wolfSSL | 15:117db924cf7c | 69 | } SrpSide; |
wolfSSL | 15:117db924cf7c | 70 | |
wolfSSL | 15:117db924cf7c | 71 | /** |
wolfSSL | 15:117db924cf7c | 72 | * SRP hash type, SHA[1|256|384|512]. |
wolfSSL | 15:117db924cf7c | 73 | */ |
wolfSSL | 15:117db924cf7c | 74 | typedef enum { |
wolfSSL | 15:117db924cf7c | 75 | SRP_TYPE_SHA = 1, |
wolfSSL | 15:117db924cf7c | 76 | SRP_TYPE_SHA256 = 2, |
wolfSSL | 15:117db924cf7c | 77 | SRP_TYPE_SHA384 = 3, |
wolfSSL | 15:117db924cf7c | 78 | SRP_TYPE_SHA512 = 4, |
wolfSSL | 15:117db924cf7c | 79 | } SrpType; |
wolfSSL | 15:117db924cf7c | 80 | |
wolfSSL | 15:117db924cf7c | 81 | |
wolfSSL | 15:117db924cf7c | 82 | /** |
wolfSSL | 15:117db924cf7c | 83 | * SRP hash struct. |
wolfSSL | 15:117db924cf7c | 84 | */ |
wolfSSL | 15:117db924cf7c | 85 | typedef struct { |
wolfSSL | 15:117db924cf7c | 86 | byte type; |
wolfSSL | 15:117db924cf7c | 87 | union { |
wolfSSL | 15:117db924cf7c | 88 | #ifndef NO_SHA |
wolfSSL | 15:117db924cf7c | 89 | wc_Sha sha; |
wolfSSL | 15:117db924cf7c | 90 | #endif |
wolfSSL | 15:117db924cf7c | 91 | #ifndef NO_SHA256 |
wolfSSL | 15:117db924cf7c | 92 | wc_Sha256 sha256; |
wolfSSL | 15:117db924cf7c | 93 | #endif |
wolfSSL | 15:117db924cf7c | 94 | #ifdef WOLFSSL_SHA384 |
wolfSSL | 15:117db924cf7c | 95 | wc_Sha384 sha384; |
wolfSSL | 15:117db924cf7c | 96 | #endif |
wolfSSL | 15:117db924cf7c | 97 | #ifdef WOLFSSL_SHA512 |
wolfSSL | 15:117db924cf7c | 98 | wc_Sha512 sha512; |
wolfSSL | 15:117db924cf7c | 99 | #endif |
wolfSSL | 15:117db924cf7c | 100 | } data; |
wolfSSL | 15:117db924cf7c | 101 | } SrpHash; |
wolfSSL | 15:117db924cf7c | 102 | |
wolfSSL | 15:117db924cf7c | 103 | typedef struct Srp { |
wolfSSL | 15:117db924cf7c | 104 | SrpSide side; /**< Client or Server, @see SrpSide. */ |
wolfSSL | 15:117db924cf7c | 105 | SrpType type; /**< Hash type, @see SrpType. */ |
wolfSSL | 15:117db924cf7c | 106 | byte* user; /**< Username, login. */ |
wolfSSL | 15:117db924cf7c | 107 | word32 userSz; /**< Username length. */ |
wolfSSL | 15:117db924cf7c | 108 | byte* salt; /**< Small salt. */ |
wolfSSL | 15:117db924cf7c | 109 | word32 saltSz; /**< Salt length. */ |
wolfSSL | 15:117db924cf7c | 110 | mp_int N; /**< Modulus. N = 2q+1, [q, N] are primes.*/ |
wolfSSL | 15:117db924cf7c | 111 | mp_int g; /**< Generator. A generator modulo N. */ |
wolfSSL | 15:117db924cf7c | 112 | byte k[SRP_MAX_DIGEST_SIZE]; /**< Multiplier parameter. k = H(N, g) */ |
wolfSSL | 15:117db924cf7c | 113 | mp_int auth; /**< Client: x = H(salt + H(user:pswd)) */ |
wolfSSL | 15:117db924cf7c | 114 | /**< Server: v = g ^ x % N */ |
wolfSSL | 15:117db924cf7c | 115 | mp_int priv; /**< Private ephemeral value. */ |
wolfSSL | 15:117db924cf7c | 116 | SrpHash client_proof; /**< Client proof. Sent to the Server. */ |
wolfSSL | 15:117db924cf7c | 117 | SrpHash server_proof; /**< Server proof. Sent to the Client. */ |
wolfSSL | 15:117db924cf7c | 118 | byte* key; /**< Session key. */ |
wolfSSL | 15:117db924cf7c | 119 | word32 keySz; /**< Session key length. */ |
wolfSSL | 15:117db924cf7c | 120 | int (*keyGenFunc_cb) (struct Srp* srp, byte* secret, word32 size); |
wolfSSL | 15:117db924cf7c | 121 | /**< Function responsible for generating the session key. */ |
wolfSSL | 15:117db924cf7c | 122 | /**< It MUST use XMALLOC with type DYNAMIC_TYPE_SRP to allocate the */ |
wolfSSL | 15:117db924cf7c | 123 | /**< key buffer for this structure and set keySz to the buffer size. */ |
wolfSSL | 15:117db924cf7c | 124 | /**< The default function used by this implementation is a modified */ |
wolfSSL | 15:117db924cf7c | 125 | /**< version of t_mgf1 that uses the proper hash function according */ |
wolfSSL | 15:117db924cf7c | 126 | /**< to srp->type. */ |
wolfSSL | 15:117db924cf7c | 127 | void* heap; /**< heap hint pointer */ |
wolfSSL | 15:117db924cf7c | 128 | } Srp; |
wolfSSL | 15:117db924cf7c | 129 | |
wolfSSL | 15:117db924cf7c | 130 | /** |
wolfSSL | 15:117db924cf7c | 131 | * Initializes the Srp struct for usage. |
wolfSSL | 15:117db924cf7c | 132 | * |
wolfSSL | 15:117db924cf7c | 133 | * @param[out] srp the Srp structure to be initialized. |
wolfSSL | 15:117db924cf7c | 134 | * @param[in] type the hash type to be used. |
wolfSSL | 15:117db924cf7c | 135 | * @param[in] side the side of the communication. |
wolfSSL | 15:117db924cf7c | 136 | * |
wolfSSL | 15:117db924cf7c | 137 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 138 | */ |
wolfSSL | 15:117db924cf7c | 139 | WOLFSSL_API int wc_SrpInit(Srp* srp, SrpType type, SrpSide side); |
wolfSSL | 15:117db924cf7c | 140 | |
wolfSSL | 15:117db924cf7c | 141 | /** |
wolfSSL | 15:117db924cf7c | 142 | * Releases the Srp struct resources after usage. |
wolfSSL | 15:117db924cf7c | 143 | * |
wolfSSL | 15:117db924cf7c | 144 | * @param[in,out] srp the Srp structure to be terminated. |
wolfSSL | 15:117db924cf7c | 145 | */ |
wolfSSL | 15:117db924cf7c | 146 | WOLFSSL_API void wc_SrpTerm(Srp* srp); |
wolfSSL | 15:117db924cf7c | 147 | |
wolfSSL | 15:117db924cf7c | 148 | /** |
wolfSSL | 15:117db924cf7c | 149 | * Sets the username. |
wolfSSL | 15:117db924cf7c | 150 | * |
wolfSSL | 15:117db924cf7c | 151 | * This function MUST be called after wc_SrpInit. |
wolfSSL | 15:117db924cf7c | 152 | * |
wolfSSL | 15:117db924cf7c | 153 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 154 | * @param[in] username the buffer containing the username. |
wolfSSL | 15:117db924cf7c | 155 | * @param[in] size the username size in bytes |
wolfSSL | 15:117db924cf7c | 156 | * |
wolfSSL | 15:117db924cf7c | 157 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 158 | */ |
wolfSSL | 15:117db924cf7c | 159 | WOLFSSL_API int wc_SrpSetUsername(Srp* srp, const byte* username, word32 size); |
wolfSSL | 15:117db924cf7c | 160 | |
wolfSSL | 15:117db924cf7c | 161 | |
wolfSSL | 15:117db924cf7c | 162 | /** |
wolfSSL | 15:117db924cf7c | 163 | * Sets the srp parameters based on the username. |
wolfSSL | 15:117db924cf7c | 164 | * |
wolfSSL | 15:117db924cf7c | 165 | * This function MUST be called after wc_SrpSetUsername. |
wolfSSL | 15:117db924cf7c | 166 | * |
wolfSSL | 15:117db924cf7c | 167 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 168 | * @param[in] N the Modulus. N = 2q+1, [q, N] are primes. |
wolfSSL | 15:117db924cf7c | 169 | * @param[in] nSz the N size in bytes. |
wolfSSL | 15:117db924cf7c | 170 | * @param[in] g the Generator modulo N. |
wolfSSL | 15:117db924cf7c | 171 | * @param[in] gSz the g size in bytes |
wolfSSL | 15:117db924cf7c | 172 | * @param[in] salt a small random salt. Specific for each username. |
wolfSSL | 15:117db924cf7c | 173 | * @param[in] saltSz the salt size in bytes |
wolfSSL | 15:117db924cf7c | 174 | * |
wolfSSL | 15:117db924cf7c | 175 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 176 | */ |
wolfSSL | 15:117db924cf7c | 177 | WOLFSSL_API int wc_SrpSetParams(Srp* srp, const byte* N, word32 nSz, |
wolfSSL | 15:117db924cf7c | 178 | const byte* g, word32 gSz, |
wolfSSL | 15:117db924cf7c | 179 | const byte* salt, word32 saltSz); |
wolfSSL | 15:117db924cf7c | 180 | |
wolfSSL | 15:117db924cf7c | 181 | /** |
wolfSSL | 15:117db924cf7c | 182 | * Sets the password. |
wolfSSL | 15:117db924cf7c | 183 | * |
wolfSSL | 15:117db924cf7c | 184 | * Setting the password does not persists the clear password data in the |
wolfSSL | 15:117db924cf7c | 185 | * srp structure. The client calculates x = H(salt + H(user:pswd)) and stores |
wolfSSL | 15:117db924cf7c | 186 | * it in the auth field. |
wolfSSL | 15:117db924cf7c | 187 | * |
wolfSSL | 15:117db924cf7c | 188 | * This function MUST be called after wc_SrpSetParams and is CLIENT SIDE ONLY. |
wolfSSL | 15:117db924cf7c | 189 | * |
wolfSSL | 15:117db924cf7c | 190 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 191 | * @param[in] password the buffer containing the password. |
wolfSSL | 15:117db924cf7c | 192 | * @param[in] size the password size in bytes. |
wolfSSL | 15:117db924cf7c | 193 | * |
wolfSSL | 15:117db924cf7c | 194 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 195 | */ |
wolfSSL | 15:117db924cf7c | 196 | WOLFSSL_API int wc_SrpSetPassword(Srp* srp, const byte* password, word32 size); |
wolfSSL | 15:117db924cf7c | 197 | |
wolfSSL | 15:117db924cf7c | 198 | /** |
wolfSSL | 15:117db924cf7c | 199 | * Sets the verifier. |
wolfSSL | 15:117db924cf7c | 200 | * |
wolfSSL | 15:117db924cf7c | 201 | * This function MUST be called after wc_SrpSetParams and is SERVER SIDE ONLY. |
wolfSSL | 15:117db924cf7c | 202 | * |
wolfSSL | 15:117db924cf7c | 203 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 204 | * @param[in] verifier the buffer containing the verifier. |
wolfSSL | 15:117db924cf7c | 205 | * @param[in] size the verifier size in bytes. |
wolfSSL | 15:117db924cf7c | 206 | * |
wolfSSL | 15:117db924cf7c | 207 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 208 | */ |
wolfSSL | 15:117db924cf7c | 209 | WOLFSSL_API int wc_SrpSetVerifier(Srp* srp, const byte* verifier, word32 size); |
wolfSSL | 15:117db924cf7c | 210 | |
wolfSSL | 15:117db924cf7c | 211 | /** |
wolfSSL | 15:117db924cf7c | 212 | * Gets the verifier. |
wolfSSL | 15:117db924cf7c | 213 | * |
wolfSSL | 15:117db924cf7c | 214 | * The client calculates the verifier with v = g ^ x % N. |
wolfSSL | 15:117db924cf7c | 215 | * This function MAY be called after wc_SrpSetPassword and is CLIENT SIDE ONLY. |
wolfSSL | 15:117db924cf7c | 216 | * |
wolfSSL | 15:117db924cf7c | 217 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 218 | * @param[out] verifier the buffer to write the verifier. |
wolfSSL | 15:117db924cf7c | 219 | * @param[in,out] size the buffer size in bytes. Will be updated with the |
wolfSSL | 15:117db924cf7c | 220 | * verifier size. |
wolfSSL | 15:117db924cf7c | 221 | * |
wolfSSL | 15:117db924cf7c | 222 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 223 | */ |
wolfSSL | 15:117db924cf7c | 224 | WOLFSSL_API int wc_SrpGetVerifier(Srp* srp, byte* verifier, word32* size); |
wolfSSL | 15:117db924cf7c | 225 | |
wolfSSL | 15:117db924cf7c | 226 | /** |
wolfSSL | 15:117db924cf7c | 227 | * Sets the private ephemeral value. |
wolfSSL | 15:117db924cf7c | 228 | * |
wolfSSL | 15:117db924cf7c | 229 | * The private ephemeral value is known as: |
wolfSSL | 15:117db924cf7c | 230 | * a at the client side. a = random() |
wolfSSL | 15:117db924cf7c | 231 | * b at the server side. b = random() |
wolfSSL | 15:117db924cf7c | 232 | * This function is handy for unit test cases or if the developer wants to use |
wolfSSL | 15:117db924cf7c | 233 | * an external random source to set the ephemeral value. |
wolfSSL | 15:117db924cf7c | 234 | * This function MAY be called before wc_SrpGetPublic. |
wolfSSL | 15:117db924cf7c | 235 | * |
wolfSSL | 15:117db924cf7c | 236 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 237 | * @param[in] priv the ephemeral value. |
wolfSSL | 15:117db924cf7c | 238 | * @param[in] size the private size in bytes. |
wolfSSL | 15:117db924cf7c | 239 | * |
wolfSSL | 15:117db924cf7c | 240 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 241 | */ |
wolfSSL | 15:117db924cf7c | 242 | WOLFSSL_API int wc_SrpSetPrivate(Srp* srp, const byte* priv, word32 size); |
wolfSSL | 15:117db924cf7c | 243 | |
wolfSSL | 15:117db924cf7c | 244 | /** |
wolfSSL | 15:117db924cf7c | 245 | * Gets the public ephemeral value. |
wolfSSL | 15:117db924cf7c | 246 | * |
wolfSSL | 15:117db924cf7c | 247 | * The public ephemeral value is known as: |
wolfSSL | 15:117db924cf7c | 248 | * A at the client side. A = g ^ a % N |
wolfSSL | 15:117db924cf7c | 249 | * B at the server side. B = (k * v + (g ˆ b % N)) % N |
wolfSSL | 15:117db924cf7c | 250 | * This function MUST be called after wc_SrpSetPassword or wc_SrpSetVerifier. |
wolfSSL | 15:117db924cf7c | 251 | * |
wolfSSL | 15:117db924cf7c | 252 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 253 | * @param[out] pub the buffer to write the public ephemeral value. |
wolfSSL | 15:117db924cf7c | 254 | * @param[in,out] size the the buffer size in bytes. Will be updated with |
wolfSSL | 15:117db924cf7c | 255 | * the ephemeral value size. |
wolfSSL | 15:117db924cf7c | 256 | * |
wolfSSL | 15:117db924cf7c | 257 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 258 | */ |
wolfSSL | 15:117db924cf7c | 259 | WOLFSSL_API int wc_SrpGetPublic(Srp* srp, byte* pub, word32* size); |
wolfSSL | 15:117db924cf7c | 260 | |
wolfSSL | 15:117db924cf7c | 261 | |
wolfSSL | 15:117db924cf7c | 262 | /** |
wolfSSL | 15:117db924cf7c | 263 | * Computes the session key. |
wolfSSL | 15:117db924cf7c | 264 | * |
wolfSSL | 15:117db924cf7c | 265 | * The key can be accessed at srp->key after success. |
wolfSSL | 15:117db924cf7c | 266 | * |
wolfSSL | 15:117db924cf7c | 267 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 268 | * @param[in] clientPubKey the client's public ephemeral value. |
wolfSSL | 15:117db924cf7c | 269 | * @param[in] clientPubKeySz the client's public ephemeral value size. |
wolfSSL | 15:117db924cf7c | 270 | * @param[in] serverPubKey the server's public ephemeral value. |
wolfSSL | 15:117db924cf7c | 271 | * @param[in] serverPubKeySz the server's public ephemeral value size. |
wolfSSL | 15:117db924cf7c | 272 | * |
wolfSSL | 15:117db924cf7c | 273 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 274 | */ |
wolfSSL | 15:117db924cf7c | 275 | WOLFSSL_API int wc_SrpComputeKey(Srp* srp, |
wolfSSL | 15:117db924cf7c | 276 | byte* clientPubKey, word32 clientPubKeySz, |
wolfSSL | 15:117db924cf7c | 277 | byte* serverPubKey, word32 serverPubKeySz); |
wolfSSL | 15:117db924cf7c | 278 | |
wolfSSL | 15:117db924cf7c | 279 | /** |
wolfSSL | 15:117db924cf7c | 280 | * Gets the proof. |
wolfSSL | 15:117db924cf7c | 281 | * |
wolfSSL | 15:117db924cf7c | 282 | * This function MUST be called after wc_SrpComputeKey. |
wolfSSL | 15:117db924cf7c | 283 | * |
wolfSSL | 15:117db924cf7c | 284 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 285 | * @param[out] proof the buffer to write the proof. |
wolfSSL | 15:117db924cf7c | 286 | * @param[in,out] size the buffer size in bytes. Will be updated with the |
wolfSSL | 15:117db924cf7c | 287 | * proof size. |
wolfSSL | 15:117db924cf7c | 288 | * |
wolfSSL | 15:117db924cf7c | 289 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 290 | */ |
wolfSSL | 15:117db924cf7c | 291 | WOLFSSL_API int wc_SrpGetProof(Srp* srp, byte* proof, word32* size); |
wolfSSL | 15:117db924cf7c | 292 | |
wolfSSL | 15:117db924cf7c | 293 | /** |
wolfSSL | 15:117db924cf7c | 294 | * Verifies the peers proof. |
wolfSSL | 15:117db924cf7c | 295 | * |
wolfSSL | 15:117db924cf7c | 296 | * This function MUST be called before wc_SrpGetSessionKey. |
wolfSSL | 15:117db924cf7c | 297 | * |
wolfSSL | 15:117db924cf7c | 298 | * @param[in,out] srp the Srp structure. |
wolfSSL | 15:117db924cf7c | 299 | * @param[in] proof the peers proof. |
wolfSSL | 15:117db924cf7c | 300 | * @param[in] size the proof size in bytes. |
wolfSSL | 15:117db924cf7c | 301 | * |
wolfSSL | 15:117db924cf7c | 302 | * @return 0 on success, {@literal <} 0 on error. @see error-crypt.h |
wolfSSL | 15:117db924cf7c | 303 | */ |
wolfSSL | 15:117db924cf7c | 304 | WOLFSSL_API int wc_SrpVerifyPeersProof(Srp* srp, byte* proof, word32 size); |
wolfSSL | 15:117db924cf7c | 305 | |
wolfSSL | 15:117db924cf7c | 306 | #ifdef __cplusplus |
wolfSSL | 15:117db924cf7c | 307 | } /* extern "C" */ |
wolfSSL | 15:117db924cf7c | 308 | #endif |
wolfSSL | 15:117db924cf7c | 309 | |
wolfSSL | 15:117db924cf7c | 310 | #endif /* WOLFCRYPT_SRP_H */ |
wolfSSL | 15:117db924cf7c | 311 | #endif /* WOLFCRYPT_HAVE_SRP */ |
wolfSSL | 15:117db924cf7c | 312 |