diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2015-03-11 17:53:03 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-12 07:58:24 +0100 |
commit | 804fae5d16c8c48c6fca8d54f2878a2e382a0bc2 (patch) | |
tree | ba56426830aef6a3ca7b5c1d2a9b808ae5361b8f /common | |
parent | 1ac61317c64f8fda2ab533200dffce5fd3edcbf6 (diff) | |
download | barebox-804fae5d16c8c48c6fca8d54f2878a2e382a0bc2.tar.gz barebox-804fae5d16c8c48c6fca8d54f2878a2e382a0bc2.tar.xz |
digest: introduce digest_{init/update/final/length}
This will allow to move from a one at a time digest to a multi-instance
with too much impact on the code using it
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/password.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/common/password.c b/common/password.c index 111c139286..16061095a8 100644 --- a/common/password.c +++ b/common/password.c @@ -282,33 +282,33 @@ static int __check_passwd(unsigned char* passwd, size_t length, int std) d = digest_get_by_name(PASSWD_SUM); - passwd1_sum = calloc(d->length, sizeof(unsigned char)); + passwd1_sum = calloc(digest_length(d), sizeof(unsigned char)); if (!passwd1_sum) return -ENOMEM; - passwd2_sum = calloc(d->length, sizeof(unsigned char)); + passwd2_sum = calloc(digest_length(d), sizeof(unsigned char)); if (!passwd2_sum) { ret = -ENOMEM; goto err1; } - d->init(d); + digest_init(d); - d->update(d, passwd, length); + digest_update(d, passwd, length); - d->final(d, passwd1_sum); + digest_final(d, passwd1_sum); if (std) - ret = read_env_passwd(passwd2_sum, d->length); + ret = read_env_passwd(passwd2_sum, digest_length(d)); else - ret = read_default_passwd(passwd2_sum, d->length); + ret = read_default_passwd(passwd2_sum, digest_length(d)); if (ret < 0) goto err2; - if (strncmp(passwd1_sum, passwd2_sum, d->length) == 0) + if (strncmp(passwd1_sum, passwd2_sum, digest_length(d)) == 0) ret = 1; err2: @@ -349,18 +349,18 @@ int set_env_passwd(unsigned char* passwd, size_t length) d = digest_get_by_name(PASSWD_SUM); - passwd_sum = calloc(d->length, sizeof(unsigned char)); + passwd_sum = calloc(digest_length(d), sizeof(unsigned char)); if (!passwd_sum) return -ENOMEM; - d->init(d); + digest_init(d); - d->update(d, passwd, length); + digest_update(d, passwd, length); - d->final(d, passwd_sum); + digest_final(d, passwd_sum); - ret = write_env_passwd(passwd_sum, d->length); + ret = write_env_passwd(passwd_sum, digest_length(d)); free(passwd_sum); |