hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 167fd96f50b4845eecc65df72e3c52e3b019a389
parent 275251b17286252a94a217a9903c43e7fee03f75
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Wed,  3 May 2023 19:51:39 +0200

argon2: rename config to conf to break api

That will make migration easier by breaking builds, if a migration has
not been done or also if a migration has been done and it's accidently
compiled with an older version of the stdlib.

Diffstat:
Mcrypto/argon2/+test.ha | 28++++++++++++++--------------
Mcrypto/argon2/argon2.ha | 20++++++++++----------
Mcrypto/keyderiv.ha | 2+-
3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/crypto/argon2/+test.ha b/crypto/argon2/+test.ha @@ -19,7 +19,7 @@ use strings; 0xc1, 0x79, ]; - let cfg = config { + let cfg = conf { secret = secret, data = data, passes = 1, @@ -51,7 +51,7 @@ use strings; 0x4a, 0xcb, ]; - let cfg = config { + let cfg = conf { secret = secret, data = data, passes = 3, @@ -84,7 +84,7 @@ use strings; 0x6c, 0xe8, ]; - let cfg = config { + let cfg = conf { secret = secret, data = data, passes = 3, @@ -116,7 +116,7 @@ use strings; 0xe6, 0x59, ]; - let cfg = config { + let cfg = conf { secret = secret, data = data, passes = 3, @@ -132,7 +132,7 @@ use strings; }; type tcase = struct { - c: config, + c: conf, m: mode, h: str, }; @@ -144,17 +144,17 @@ type tcase = struct { const tests: [_]tcase = [ // XXX disabled for now because it's slow // tcase { - // c = low_mem_config, + // c = low_mem_conf, // m = mode::ID, // h = "8974537c53677aae532b319af700bb4232a0d74eee7d57296b2a3f8303a6bafe", // }, // tcase { - // c = default_config, + // c = default_conf, // m = mode::ID, // h = "3b282cbf435b0e022f7041549583ddc802e519109f1da8f12d2054910913d660", // }, tcase { - c = config { + c = conf { passes = 1, parallel = 3, version = 0x13, @@ -165,7 +165,7 @@ type tcase = struct { h = "c7ada5ba3222fa45a3802249b509dcfb10e68a50e3faad2a6377eeca8395ab47", }, tcase { - c = config { + c = conf { passes = 1, parallel = 4, version = 0x13, @@ -176,7 +176,7 @@ type tcase = struct { h = "21543b2017ede3f865ea5cb88295628ba25eb3be53a8c4aeb0ac1a264be0110a", }, tcase { - c = config { + c = conf { passes = 1, parallel = 4, version = 0x13, @@ -187,7 +187,7 @@ type tcase = struct { h = "5c3124ce5f3556e5e25f06b5108718f2cd72afee98a3249656eb85ecc0e5b314", }, tcase { - c = config { + c = conf { passes = 1, parallel = 4, version = 0x13, @@ -198,7 +198,7 @@ type tcase = struct { h = "d75524ad0b899363ce77f2d1e1040763dc01cfc725db635391bba163001f08cb", }, tcase { - c = config { + c = conf { passes = 3, parallel = 3, version = 0x13, @@ -209,7 +209,7 @@ type tcase = struct { h = "226c3ca6caba42b102035d332a11b350f1e19675fccb6e24aa33ca8c31d588c1", }, tcase { - c = config { + c = conf { passes = 1, parallel = 8, version = 0x13, @@ -220,7 +220,7 @@ type tcase = struct { h = "fadf598b70708f4d91b0e98f038fd25a73950f1f85d57fb250740d817f95e9a9", }, tcase { - c = config { + c = conf { passes = 1, parallel = 4, version = 0x13, diff --git a/crypto/argon2/argon2.ha b/crypto/argon2/argon2.ha @@ -54,7 +54,7 @@ type mode = enum { // blocks, and must be a multiple of [[BLOCKSIZE]]. To have the implementation // allocate 64 KiB, set 'mem' to 64. To use the same amount of caller-provided // memory, provide a slice of length 64 * [[BLOCKSIZE]]. -export type config = struct { +export type conf = struct { mem: (u32 | []u64), parallel: u32, passes: u32, @@ -66,7 +66,7 @@ export type config = struct { // The default recommended configuration for most use cases. This configuration // uses 2 GiB of working memory. A 16-byte 'salt' and 32-byte 'dest' parameter // is recommended in combination with this configuration. -export const default_config: config = config { +export const default_conf: conf = conf { mem = 2 * 1024 * 1024, passes = 1, parallel = 4, @@ -77,7 +77,7 @@ export const default_config: config = config { // The default recommended configuration for memory-constrained use cases. This // configuration uses 64 MiB of working memory. A 16-byte 'salt' and 32-byte // 'dest' parameter is recommended in combination with this configuration. -export const low_mem_config: config = config { +export const low_mem_conf: conf = conf { mem = 64 * 1024, passes = 3, parallel = 4, @@ -106,7 +106,7 @@ export fn argon2d( dest: []u8, password: []u8, salt: []u8, - cfg: *config, + cfg: *conf, ) (void | nomem) = { return argon2(dest, password, salt, cfg, mode::D); }; @@ -122,7 +122,7 @@ export fn argon2i( dest: []u8, password: []u8, salt: []u8, - cfg: *config, + cfg: *conf, ) (void | nomem) = { return argon2(dest, password, salt, cfg, mode::I); }; @@ -140,7 +140,7 @@ export fn argon2id( dest: []u8, password: []u8, salt: []u8, - cfg: *config, + cfg: *conf, ) (void | nomem) = { return argon2(dest, password, salt, cfg, mode::ID); }; @@ -149,7 +149,7 @@ fn argon2( dest: []u8, password: []u8, salt: []u8, - cfg: *config, + cfg: *conf, mode: mode, ) (void | nomem) = { assert(endian::host == &endian::little, "TODO big endian support"); @@ -249,7 +249,7 @@ fn blocku8(ctx: *context, i: size, j: size) []u8 = { return (block(ctx, i, j): *[*]u8)[..BLOCKSIZE * size(u64)]; }; -fn refblock(cfg: *config, ctx: *context, seed: u64, i: size, j: size) []u64 = { +fn refblock(cfg: *conf, ctx: *context, seed: u64, i: size, j: size) []u64 = { const segstart = (j - (j % ctx.sliceblocks)) / ctx.sliceblocks; const index = j % ctx.sliceblocks; @@ -291,7 +291,7 @@ fn inithash( taglen: u32, password: []u8, salt: []u8, - cfg: *config, + cfg: *conf, mode: mode, memsize: u32, ) void = { @@ -384,7 +384,7 @@ fn xorblock(dest: []u64, x: []u64, y: []u64) void = { (y: *[*]u8)[..len(dest) * size(u64)]); }; -fn segproc(cfg: *config, ctx: *context, i: size, slice: size) void = { +fn segproc(cfg: *conf, ctx: *context, i: size, slice: size) void = { const init = switch (ctx.mode) { case mode::I => yield true; diff --git a/crypto/keyderiv.ha b/crypto/keyderiv.ha @@ -41,7 +41,7 @@ export fn derivekey( mem: (u32 | []u64), passes: u32, ) (void | errors::nomem) = { - const config = argon2::config { + const config = argon2::conf { mem = mem, parallel = 1, passes = passes + 3,