diff options
author | Greg Hudson <ghudson@mit.edu> | 2009-11-28 00:43:34 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2009-11-28 00:43:34 +0000 |
commit | 65577cf37ab5831e736dd5db8459c0927cd3e224 (patch) | |
tree | 49d60364bcfaa50cd849568b7313d92e1388d28c /src/lib/crypto/krb/make_checksum.c | |
parent | 9fde1f049d4f2205a9cccdc82278d93e6eaad748 (diff) | |
download | krb5-65577cf37ab5831e736dd5db8459c0927cd3e224.zip krb5-65577cf37ab5831e736dd5db8459c0927cd3e224.tar.gz krb5-65577cf37ab5831e736dd5db8459c0927cd3e224.tar.bz2 |
Mark and reindent lib/crypto
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23374 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/krb/make_checksum.c')
-rw-r--r-- | src/lib/crypto/krb/make_checksum.c | 101 |
1 files changed, 51 insertions, 50 deletions
diff --git a/src/lib/crypto/krb/make_checksum.c b/src/lib/crypto/krb/make_checksum.c index 06a5247..f62f40a 100644 --- a/src/lib/crypto/krb/make_checksum.c +++ b/src/lib/crypto/krb/make_checksum.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (C) 1998 by the FundsXpress, INC. * @@ -31,8 +32,8 @@ krb5_error_code KRB5_CALLCONV krb5_k_make_checksum(krb5_context context, krb5_cksumtype cksumtype, - krb5_key key, krb5_keyusage usage, - const krb5_data *input, krb5_checksum *cksum) + krb5_key key, krb5_keyusage usage, + const krb5_data *input, krb5_checksum *cksum) { unsigned int i; const struct krb5_cksumtypes *ctp; @@ -44,73 +45,73 @@ krb5_k_make_checksum(krb5_context context, krb5_cksumtype cksumtype, size_t cksumlen; for (i = 0; i < krb5int_cksumtypes_length; i++) { - if (krb5int_cksumtypes_list[i].ctype == cksumtype) - break; + if (krb5int_cksumtypes_list[i].ctype == cksumtype) + break; } if (i == krb5int_cksumtypes_length) - return KRB5_BAD_ENCTYPE; + return KRB5_BAD_ENCTYPE; ctp = &krb5int_cksumtypes_list[i]; if (ctp->keyhash != NULL) - cksumlen = ctp->keyhash->hashsize; + cksumlen = ctp->keyhash->hashsize; else - cksumlen = ctp->hash->hashsize; + cksumlen = ctp->hash->hashsize; cksum->length = cksumlen; cksum->contents = malloc(cksum->length); if (cksum->contents == NULL) - return ENOMEM; + return ENOMEM; data.length = cksum->length; data.data = (char *) cksum->contents; if (ctp->keyhash) { - /* check if key is compatible */ - if (ctp->keyed_etype) { - ktp1 = find_enctype(ctp->keyed_etype); - ktp2 = key ? find_enctype(key->keyblock.enctype) : NULL; - if (ktp1 == NULL || ktp2 == NULL || ktp1->enc != ktp2->enc) { - ret = KRB5_BAD_ENCTYPE; - goto cleanup; - } - } - - keyhash = ctp->keyhash; - if (keyhash->hash == NULL) { - krb5_crypto_iov iov[1]; - - iov[0].flags = KRB5_CRYPTO_TYPE_DATA; - iov[0].data.data = input->data; - iov[0].data.length = input->length; - - assert(keyhash->hash_iov != NULL); - - ret = (*keyhash->hash_iov)(key, usage, 0, iov, 1, &data); - } else { - ret = (*keyhash->hash)(key, usage, 0, input, &data); - } + /* check if key is compatible */ + if (ctp->keyed_etype) { + ktp1 = find_enctype(ctp->keyed_etype); + ktp2 = key ? find_enctype(key->keyblock.enctype) : NULL; + if (ktp1 == NULL || ktp2 == NULL || ktp1->enc != ktp2->enc) { + ret = KRB5_BAD_ENCTYPE; + goto cleanup; + } + } + + keyhash = ctp->keyhash; + if (keyhash->hash == NULL) { + krb5_crypto_iov iov[1]; + + iov[0].flags = KRB5_CRYPTO_TYPE_DATA; + iov[0].data.data = input->data; + iov[0].data.length = input->length; + + assert(keyhash->hash_iov != NULL); + + ret = (*keyhash->hash_iov)(key, usage, 0, iov, 1, &data); + } else { + ret = (*keyhash->hash)(key, usage, 0, input, &data); + } } else if (ctp->flags & KRB5_CKSUMFLAG_DERIVE) { - ret = krb5int_dk_make_checksum(ctp->hash, key, usage, input, &data); + ret = krb5int_dk_make_checksum(ctp->hash, key, usage, input, &data); } else { - /* No key is used. */ - ret = (*ctp->hash->hash)(1, input, &data); + /* No key is used. */ + ret = (*ctp->hash->hash)(1, input, &data); } if (!ret) { - cksum->magic = KV5M_CHECKSUM; - cksum->checksum_type = cksumtype; - if (ctp->trunc_size) { - cksum->length = ctp->trunc_size; - trunc = realloc(cksum->contents, cksum->length); - if (trunc) - cksum->contents = trunc; - } + cksum->magic = KV5M_CHECKSUM; + cksum->checksum_type = cksumtype; + if (ctp->trunc_size) { + cksum->length = ctp->trunc_size; + trunc = realloc(cksum->contents, cksum->length); + if (trunc) + cksum->contents = trunc; + } } cleanup: if (ret) { - zapfree(cksum->contents, cksum->length); - cksum->contents = NULL; + zapfree(cksum->contents, cksum->length); + cksum->contents = NULL; } return ret; @@ -118,16 +119,16 @@ cleanup: krb5_error_code KRB5_CALLCONV krb5_c_make_checksum(krb5_context context, krb5_cksumtype cksumtype, - const krb5_keyblock *keyblock, krb5_keyusage usage, - const krb5_data *input, krb5_checksum *cksum) + const krb5_keyblock *keyblock, krb5_keyusage usage, + const krb5_data *input, krb5_checksum *cksum) { krb5_key key = NULL; krb5_error_code ret; if (keyblock != NULL) { - ret = krb5_k_create_key(context, keyblock, &key); - if (ret != 0) - return ret; + ret = krb5_k_create_key(context, keyblock, &key); + if (ret != 0) + return ret; } ret = krb5_k_make_checksum(context, cksumtype, key, usage, input, cksum); krb5_k_free_key(context, key); |