diff options
| author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-09-06 17:20:33 +0200 |
|---|---|---|
| committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-09-06 17:26:58 +0200 |
| commit | e6177630198eb1eea2def0374fae1196da0e40ec (patch) | |
| tree | 704951804609999fb6ef7a956b04921b9f84c320 /libtomcrypt/hashes | |
| parent | 943f9ab50c110133a5cd1118b5b19cb09301168f (diff) | |
| download | cryptodev-linux-e6177630198eb1eea2def0374fae1196da0e40ec.tar.gz cryptodev-linux-e6177630198eb1eea2def0374fae1196da0e40ec.tar.xz cryptodev-linux-e6177630198eb1eea2def0374fae1196da0e40ec.zip | |
Run Lindent on libtom(*)
Diffstat (limited to 'libtomcrypt/hashes')
| -rw-r--r-- | libtomcrypt/hashes/crypt_hash_is_valid.c | 4 | ||||
| -rw-r--r-- | libtomcrypt/hashes/hash_get_oid.c | 72 | ||||
| -rw-r--r-- | libtomcrypt/hashes/hash_memory.c | 58 | ||||
| -rw-r--r-- | libtomcrypt/hashes/hash_memory_multi.c | 94 |
4 files changed, 114 insertions, 114 deletions
diff --git a/libtomcrypt/hashes/crypt_hash_is_valid.c b/libtomcrypt/hashes/crypt_hash_is_valid.c index d01d418..59320a3 100644 --- a/libtomcrypt/hashes/crypt_hash_is_valid.c +++ b/libtomcrypt/hashes/crypt_hash_is_valid.c @@ -13,7 +13,7 @@ /** @file crypt_hash_is_valid.c Determine if hash is valid, Tom St Denis -*/ +*/ /* Test if a hash index is valid @@ -22,7 +22,7 @@ */ int hash_is_valid(const struct algo_properties_st *hash) { - return CRYPT_OK; + return CRYPT_OK; } /* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c,v $ */ diff --git a/libtomcrypt/hashes/hash_get_oid.c b/libtomcrypt/hashes/hash_get_oid.c index 39f4372..835ffb1 100644 --- a/libtomcrypt/hashes/hash_get_oid.c +++ b/libtomcrypt/hashes/hash_get_oid.c @@ -17,60 +17,60 @@ */ static const oid_st sha1_oid = { - .OIDlen = 6, - .OID = { 1, 3, 14, 3, 2, 26 }, + .OIDlen = 6, + .OID = {1, 3, 14, 3, 2, 26}, }; static const oid_st md5_oid = { - .OIDlen = 6, - .OID = { 1, 2, 840, 113549, 2, 5, }, + .OIDlen = 6, + .OID = {1, 2, 840, 113549, 2, 5,}, }; static const oid_st sha224_oid = { - .OIDlen = 9, - .OID = { 2, 16, 840, 1, 101, 3, 4, 2, 4, }, + .OIDlen = 9, + .OID = {2, 16, 840, 1, 101, 3, 4, 2, 4,}, }; static const oid_st sha256_oid = { - .OIDlen = 9, - .OID = { 2, 16, 840, 1, 101, 3, 4, 2, 1, }, + .OIDlen = 9, + .OID = {2, 16, 840, 1, 101, 3, 4, 2, 1,}, }; static const oid_st sha384_oid = { - .OIDlen = 9, - .OID = { 2, 16, 840, 1, 101, 3, 4, 2, 2, }, + .OIDlen = 9, + .OID = {2, 16, 840, 1, 101, 3, 4, 2, 2,}, }; static const oid_st sha512_oid = { - .OIDlen = 9, - .OID = { 2, 16, 840, 1, 101, 3, 4, 2, 3, }, + .OIDlen = 9, + .OID = {2, 16, 840, 1, 101, 3, 4, 2, 3,}, }; -int hash_get_oid(const struct algo_properties_st *hash, oid_st *st) +int hash_get_oid(const struct algo_properties_st *hash, oid_st * st) { - switch (hash->algo) { - case NCR_ALG_SHA1: - memcpy(st, &sha1_oid, sizeof(*st)); - break; - case NCR_ALG_MD5: - memcpy(st, &md5_oid, sizeof(*st)); - break; - case NCR_ALG_SHA2_224: - memcpy(st, &sha224_oid, sizeof(*st)); - break; - case NCR_ALG_SHA2_256: - memcpy(st, &sha256_oid, sizeof(*st)); - break; - case NCR_ALG_SHA2_384: - memcpy(st, &sha384_oid, sizeof(*st)); - break; - case NCR_ALG_SHA2_512: - memcpy(st, &sha512_oid, sizeof(*st)); - break; - default: - return CRYPT_INVALID_ARG; - } - return CRYPT_OK; + switch (hash->algo) { + case NCR_ALG_SHA1: + memcpy(st, &sha1_oid, sizeof(*st)); + break; + case NCR_ALG_MD5: + memcpy(st, &md5_oid, sizeof(*st)); + break; + case NCR_ALG_SHA2_224: + memcpy(st, &sha224_oid, sizeof(*st)); + break; + case NCR_ALG_SHA2_256: + memcpy(st, &sha256_oid, sizeof(*st)); + break; + case NCR_ALG_SHA2_384: + memcpy(st, &sha384_oid, sizeof(*st)); + break; + case NCR_ALG_SHA2_512: + memcpy(st, &sha512_oid, sizeof(*st)); + break; + default: + return CRYPT_INVALID_ARG; + } + return CRYPT_OK; } /* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c,v $ */ diff --git a/libtomcrypt/hashes/hash_memory.c b/libtomcrypt/hashes/hash_memory.c index c6f5188..ed1425f 100644 --- a/libtomcrypt/hashes/hash_memory.c +++ b/libtomcrypt/hashes/hash_memory.c @@ -26,41 +26,41 @@ @param outlen [in/out] Max size and resulting size of the digest @return CRYPT_OK if successful */ -int hash_memory(const struct algo_properties_st *hash, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen) +int hash_memory(const struct algo_properties_st *hash, const unsigned char *in, + unsigned long inlen, unsigned char *out, unsigned long *outlen) { - int err; - struct hash_data hdata; + int err; + struct hash_data hdata; - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); - if ((err = hash_is_valid(hash)) != CRYPT_OK) { - return err; - } + if ((err = hash_is_valid(hash)) != CRYPT_OK) { + return err; + } - if (*outlen < hash->digest_size) { - *outlen = hash->digest_size; - return CRYPT_BUFFER_OVERFLOW; - } + if (*outlen < hash->digest_size) { + *outlen = hash->digest_size; + return CRYPT_BUFFER_OVERFLOW; + } - err = cryptodev_hash_init(&hdata, hash->kstr, NULL, 0); - if (err < 0) { - err = CRYPT_INVALID_HASH; - goto LBL_ERR; - } + err = cryptodev_hash_init(&hdata, hash->kstr, NULL, 0); + if (err < 0) { + err = CRYPT_INVALID_HASH; + goto LBL_ERR; + } - if ((err = _cryptodev_hash_update(&hdata, in, inlen)) < 0) { - err = CRYPT_ERROR; - goto LBL_ERR; - } - - err = cryptodev_hash_final(&hdata, out); - - *outlen = hash->digest_size; + if ((err = _cryptodev_hash_update(&hdata, in, inlen)) < 0) { + err = CRYPT_ERROR; + goto LBL_ERR; + } + + err = cryptodev_hash_final(&hdata, out); + + *outlen = hash->digest_size; LBL_ERR: - cryptodev_hash_deinit(&hdata); + cryptodev_hash_deinit(&hdata); - return err; + return err; } - diff --git a/libtomcrypt/hashes/hash_memory_multi.c b/libtomcrypt/hashes/hash_memory_multi.c index 7422676..d4d581e 100644 --- a/libtomcrypt/hashes/hash_memory_multi.c +++ b/libtomcrypt/hashes/hash_memory_multi.c @@ -27,58 +27,58 @@ @param inlen The length of the data to hash (octets) @param ... tuples of (data,len) pairs to hash, terminated with a (NULL,x) (x=don't care) @return CRYPT_OK if successful -*/ -int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...) +*/ +int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out, + unsigned long *outlen, const unsigned char *in, + unsigned long inlen, ...) { - struct hash_data hdata; - int err; - va_list args; - const unsigned char *curptr; - unsigned long curlen; + struct hash_data hdata; + int err; + va_list args; + const unsigned char *curptr; + unsigned long curlen; + + LTC_ARGCHK(in != NULL); + LTC_ARGCHK(out != NULL); + LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); + if ((err = hash_is_valid(hash)) != CRYPT_OK) { + return err; + } - if ((err = hash_is_valid(hash)) != CRYPT_OK) { - return err; - } + if (*outlen < hash->digest_size) { + *outlen = hash->digest_size; + return CRYPT_BUFFER_OVERFLOW; + } - if (*outlen < hash->digest_size) { - *outlen = hash->digest_size; - return CRYPT_BUFFER_OVERFLOW; - } + err = cryptodev_hash_init(&hdata, hash->kstr, NULL, 0); + if (err < 0) { + err = CRYPT_INVALID_HASH; + goto LBL_ERR; + } - err = cryptodev_hash_init(&hdata, hash->kstr, NULL, 0); - if (err < 0) { - err = CRYPT_INVALID_HASH; - goto LBL_ERR; - } + va_start(args, inlen); + curptr = in; + curlen = inlen; + for (;;) { + /* process buf */ + if ((err = _cryptodev_hash_update(&hdata, curptr, curlen)) < 0) { + err = CRYPT_ERROR; + goto LBL_ERR; + } + /* step to next */ + curptr = va_arg(args, const unsigned char *); + if (curptr == NULL) { + break; + } + curlen = va_arg(args, unsigned long); + } - va_start(args, inlen); - curptr = in; - curlen = inlen; - for (;;) { - /* process buf */ - if ((err = _cryptodev_hash_update(&hdata, curptr, curlen)) < 0) { - err = CRYPT_ERROR; - goto LBL_ERR; - } - /* step to next */ - curptr = va_arg(args, const unsigned char*); - if (curptr == NULL) { - break; - } - curlen = va_arg(args, unsigned long); - } - - err = cryptodev_hash_final(&hdata, out); - - *outlen = hash->digest_size; + err = cryptodev_hash_final(&hdata, out); + + *outlen = hash->digest_size; LBL_ERR: - cryptodev_hash_deinit(&hdata); - va_end(args); - return err; + cryptodev_hash_deinit(&hdata); + va_end(args); + return err; } - |
