Overview
Comment: | Move parameters for of_pbkdf2() to a struct
This should make it more readable for such a large number of parameters. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b9641347e3283399a085af807f6f98c8 |
User & Date: | js on 2020-06-21 21:30:23 |
Other Links: | manifest | tags |
Context
2020-06-21
| ||
22:08 | Move parameters for of_scrypt() to a struct check-in: 63f5276b33 user: js tags: trunk | |
21:30 | Move parameters for of_pbkdf2() to a struct check-in: b9641347e3 user: js tags: trunk | |
17:53 | Throw an exception when there is no name server check-in: f3573582e1 user: js tags: trunk | |
Changes
Modified src/pbkdf2.h from [e1a5b71855] to [139e147fae].
︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - - - - + - - - | OF_ASSUME_NONNULL_BEGIN /*! @file */ @class OFHMAC; /*! * @brief The parameters for @ref of_pbkdf2. */ typedef struct of_pbkdf2_parameters_t { /*! @brief The HMAC to use to derive a key. */ OFHMAC *HMAC; /*! @brief The number of iterations to perform. */ size_t iterations; /*! @brief The salt to derive a key with. */ const unsigned char *salt; /*! @brief The length of the salt. */ size_t saltLength; /*! @brief The password to derive a key from. */ const char *password; /*! @brief The length of the password. */ size_t passwordLength; /*! @brief The buffer to write the key to. */ unsigned char *key; /*! * @brief The desired length for the derived key. * * @ref key needs to have enough storage). */ size_t keyLength; /*! @brief Whether data may be stored in swappable memory. */ bool allowsSwappableMemory; } of_pbkdf2_parameters_t; #ifdef __cplusplus extern "C" { #endif /*! * @brief Derives a key from a password and a salt using PBKDF2. * * @note This will call @ref OFHMAC::reset on the `HMAC` first, making it * possible to reuse the `HMAC`, but also meaning all previous results * from the `HMAC` get invalidated if they have not been copied. * |
Modified src/pbkdf2.m from [7bd85babf9] to [ae8f98e1e6].
︙ | |||
24 25 26 27 28 29 30 | 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | + - + - - - - + - + - + - - + + - - + + - + - - + + + - - + + - + - + - + - - - - - + + + + + - - - - - + + + + + + - - + + - - - + + + - + | #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "pbkdf2.h" void |
Modified src/scrypt.m from [bf0f4f5521] to [42e8413fd6].
︙ | |||
181 182 183 184 185 186 187 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | + + + + + + - - - + + + + + + + + - - - + + + + + + + + | allowsSwappableMemory: allowsSwappableMemory]; bufferItems = buffer.mutableItems; HMAC = [[OFHMAC alloc] initWithHashClass: [OFSHA256Hash class] allowsSwappableMemory: allowsSwappableMemory]; of_pbkdf2((of_pbkdf2_parameters_t){ .HMAC = HMAC, .iterations = 1, .salt = salt, .saltLength = saltLength, .password = password, |
Modified tests/PBKDF2Tests.m from [ce7ed4d1cb] to [f87038c7c8].
︙ | |||
30 31 32 33 34 35 36 | 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | + + + - - + + + + + + + + + + + - - + + + + + + + + + + + - - + + + + + + + + + + + - - + + + + + + + + - - - + + + + + + + + + + + + + + - - + + + + + + + + | OFHMAC *HMAC = [OFHMAC HMACWithHashClass: [OFSHA1Hash class] allowsSwappableMemory: true]; unsigned char key[25]; /* Test vectors from RFC 6070 */ TEST(@"PBKDF2-SHA1, 1 iteration", R(of_pbkdf2((of_pbkdf2_parameters_t){ .HMAC = HMAC, .iterations = 1, |