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/old | |
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/old')
-rw-r--r-- | src/lib/crypto/krb/old/des_stringtokey.c | 23 | ||||
-rw-r--r-- | src/lib/crypto/krb/old/old.h | 41 | ||||
-rw-r--r-- | src/lib/crypto/krb/old/old_decrypt.c | 79 | ||||
-rw-r--r-- | src/lib/crypto/krb/old/old_encrypt.c | 43 |
4 files changed, 94 insertions, 92 deletions
diff --git a/src/lib/crypto/krb/old/des_stringtokey.c b/src/lib/crypto/krb/old/des_stringtokey.c index 6a5c669..6f49166 100644 --- a/src/lib/crypto/krb/old/des_stringtokey.c +++ b/src/lib/crypto/krb/old/des_stringtokey.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (C) 1998 by the FundsXpress, INC. * @@ -31,28 +32,28 @@ /* XXX */ extern krb5_error_code mit_des_string_to_key_int (krb5_keyblock * keyblock, - const krb5_data * data, - const krb5_data * salt); + const krb5_data * data, + const krb5_data * salt); krb5_error_code krb5int_des_string_to_key(const struct krb5_enc_provider *enc, - const krb5_data *string, - const krb5_data *salt, const krb5_data *parm, - krb5_keyblock *key) + const krb5_data *string, + const krb5_data *salt, const krb5_data *parm, + krb5_keyblock *key) { int type; if (parm ) { - if (parm->length != 1) - return KRB5_ERR_BAD_S2K_PARAMS; - type = parm->data[0]; + if (parm->length != 1) + return KRB5_ERR_BAD_S2K_PARAMS; + type = parm->data[0]; } else type = 0; switch(type) { case 0: - return(mit_des_string_to_key_int(key, string, salt)); + return(mit_des_string_to_key_int(key, string, salt)); case 1: - return mit_afs_string_to_key(key, string, salt); + return mit_afs_string_to_key(key, string, salt); default: - return KRB5_ERR_BAD_S2K_PARAMS; + return KRB5_ERR_BAD_S2K_PARAMS; } } diff --git a/src/lib/crypto/krb/old/old.h b/src/lib/crypto/krb/old/old.h index 953e61e..1ed19a0 100644 --- a/src/lib/crypto/krb/old/old.h +++ b/src/lib/crypto/krb/old/old.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (C) 1998 by the FundsXpress, INC. * @@ -26,27 +27,25 @@ #include "k5-int.h" -void krb5int_old_encrypt_length -(const struct krb5_enc_provider *enc, - const struct krb5_hash_provider *hash, - size_t input, size_t *length); +void krb5int_old_encrypt_length(const struct krb5_enc_provider *enc, + const struct krb5_hash_provider *hash, + size_t input, size_t *length); -krb5_error_code krb5int_old_encrypt -(const struct krb5_enc_provider *enc, - const struct krb5_hash_provider *hash, - krb5_key key, krb5_keyusage usage, - const krb5_data *ivec, const krb5_data *input, - krb5_data *output); +krb5_error_code krb5int_old_encrypt(const struct krb5_enc_provider *enc, + const struct krb5_hash_provider *hash, + krb5_key key, krb5_keyusage usage, + const krb5_data *ivec, + const krb5_data *input, krb5_data *output); -krb5_error_code krb5int_old_decrypt -(const struct krb5_enc_provider *enc, - const struct krb5_hash_provider *hash, - krb5_key key, krb5_keyusage usage, - const krb5_data *ivec, const krb5_data *input, - krb5_data *arg_output); +krb5_error_code krb5int_old_decrypt(const struct krb5_enc_provider *enc, + const struct krb5_hash_provider *hash, + krb5_key key, krb5_keyusage usage, + const krb5_data *ivec, + const krb5_data *input, + krb5_data *arg_output); -krb5_error_code krb5int_des_string_to_key -(const struct krb5_enc_provider *enc, - const krb5_data *string, const krb5_data *salt, - const krb5_data *params, - krb5_keyblock *key); +krb5_error_code krb5int_des_string_to_key(const struct krb5_enc_provider *enc, + const krb5_data *string, + const krb5_data *salt, + const krb5_data *params, + krb5_keyblock *key); diff --git a/src/lib/crypto/krb/old/old_decrypt.c b/src/lib/crypto/krb/old/old_decrypt.c index 97fbe6d..47996be 100644 --- a/src/lib/crypto/krb/old/old_decrypt.c +++ b/src/lib/crypto/krb/old/old_decrypt.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (C) 1998 by the FundsXpress, INC. * @@ -29,12 +30,12 @@ krb5_error_code krb5int_old_decrypt(const struct krb5_enc_provider *enc, - const struct krb5_hash_provider *hash, - krb5_key key, - krb5_keyusage usage, - const krb5_data *ivec, - const krb5_data *input, - krb5_data *arg_output) + const struct krb5_hash_provider *hash, + krb5_key key, + krb5_keyusage usage, + const krb5_data *ivec, + const krb5_data *input, + krb5_data *arg_output) { krb5_error_code ret; size_t blocksize, hashsize, plainsize; @@ -48,53 +49,53 @@ krb5int_old_decrypt(const struct krb5_enc_provider *enc, plainsize = input->length - blocksize - hashsize; if (arg_output->length < plainsize) - return(KRB5_BAD_MSIZE); + return(KRB5_BAD_MSIZE); /* if there's enough space to work in the app buffer, use it, otherwise allocate our own */ if ((cksumdata = (unsigned char *) malloc(hashsize)) == NULL) - return(ENOMEM); + return(ENOMEM); if (arg_output->length < input->length) { - output.length = input->length; + output.length = input->length; - if ((output.data = (char *) malloc(output.length)) == NULL) { - free(cksumdata); - return(ENOMEM); - } + if ((output.data = (char *) malloc(output.length)) == NULL) { + free(cksumdata); + return(ENOMEM); + } - alloced = 1; + alloced = 1; } else { - output.length = input->length; + output.length = input->length; - output.data = arg_output->data; + output.data = arg_output->data; - alloced = 0; + alloced = 0; } /* decrypt it */ /* save last ciphertext block in case we decrypt in place */ if (ivec != NULL && ivec->length == blocksize) { - cn = malloc(blocksize); - if (cn == NULL) { - ret = ENOMEM; - goto cleanup; - } - memcpy(cn, input->data + input->length - blocksize, blocksize); + cn = malloc(blocksize); + if (cn == NULL) { + ret = ENOMEM; + goto cleanup; + } + memcpy(cn, input->data + input->length - blocksize, blocksize); } else - cn = NULL; + cn = NULL; /* XXX this is gross, but I don't have much choice */ if ((key->keyblock.enctype == ENCTYPE_DES_CBC_CRC) && (ivec == 0)) { - crcivec.length = key->keyblock.length; - crcivec.data = (char *) key->keyblock.contents; - ivec = &crcivec; + crcivec.length = key->keyblock.length; + crcivec.data = (char *) key->keyblock.contents; + ivec = &crcivec; } if ((ret = ((*(enc->decrypt))(key, ivec, input, &output)))) - goto cleanup; + goto cleanup; /* verify the checksum */ @@ -105,38 +106,38 @@ krb5int_old_decrypt(const struct krb5_enc_provider *enc, cksum.data = output.data+blocksize; if ((ret = ((*(hash->hash))(1, &output, &cksum)))) - goto cleanup; + goto cleanup; if (memcmp(cksum.data, cksumdata, cksum.length) != 0) { - ret = KRB5KRB_AP_ERR_BAD_INTEGRITY; - goto cleanup; + ret = KRB5KRB_AP_ERR_BAD_INTEGRITY; + goto cleanup; } /* copy the plaintext around */ if (alloced) { - memcpy(arg_output->data, output.data+blocksize+hashsize, - plainsize); + memcpy(arg_output->data, output.data+blocksize+hashsize, + plainsize); } else { - memmove(arg_output->data, arg_output->data+blocksize+hashsize, - plainsize); + memmove(arg_output->data, arg_output->data+blocksize+hashsize, + plainsize); } arg_output->length = plainsize; /* update ivec */ if (cn != NULL) - memcpy(ivec->data, cn, blocksize); + memcpy(ivec->data, cn, blocksize); ret = 0; cleanup: if (alloced) { - memset(output.data, 0, output.length); - free(output.data); + memset(output.data, 0, output.length); + free(output.data); } if (cn != NULL) - free(cn); + free(cn); memset(cksumdata, 0, hashsize); free(cksumdata); return(ret); diff --git a/src/lib/crypto/krb/old/old_encrypt.c b/src/lib/crypto/krb/old/old_encrypt.c index 137d6ed..1903a6c 100644 --- a/src/lib/crypto/krb/old/old_encrypt.c +++ b/src/lib/crypto/krb/old/old_encrypt.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (C) 1998 by the FundsXpress, INC. * @@ -29,9 +30,9 @@ void krb5int_old_encrypt_length(const struct krb5_enc_provider *enc, - const struct krb5_hash_provider *hash, - size_t inputlen, - size_t *length) + const struct krb5_hash_provider *hash, + size_t inputlen, + size_t *length) { size_t blocksize, hashsize; @@ -43,12 +44,12 @@ krb5int_old_encrypt_length(const struct krb5_enc_provider *enc, krb5_error_code krb5int_old_encrypt(const struct krb5_enc_provider *enc, - const struct krb5_hash_provider *hash, - krb5_key key, - krb5_keyusage usage, - const krb5_data *ivec, - const krb5_data *input, - krb5_data *output) + const struct krb5_hash_provider *hash, + krb5_key key, + krb5_keyusage usage, + const krb5_data *ivec, + const krb5_data *input, + krb5_data *output) { krb5_error_code ret; size_t blocksize, hashsize, enclen; @@ -61,7 +62,7 @@ krb5int_old_encrypt(const struct krb5_enc_provider *enc, krb5int_old_encrypt_length(enc, hash, input->length, &enclen); if (output->length < enclen) - return(KRB5_BAD_MSIZE); + return(KRB5_BAD_MSIZE); output->length = enclen; @@ -73,7 +74,7 @@ krb5int_old_encrypt(const struct krb5_enc_provider *enc, datain.data = output->data; if ((ret = krb5_c_random_make_octets(/* XXX */ 0, &datain))) - return(ret); + return(ret); memcpy(output->data+blocksize+hashsize, input->data, input->length); /* compute the checksum */ @@ -82,29 +83,29 @@ krb5int_old_encrypt(const struct krb5_enc_provider *enc, datain.data = output->data+blocksize; if ((ret = ((*(hash->hash))(1, output, &datain)))) - goto cleanup; + goto cleanup; /* encrypt it */ /* XXX this is gross, but I don't have much choice */ if ((key->keyblock.enctype == ENCTYPE_DES_CBC_CRC) && (ivec == 0)) { - crcivec.length = key->keyblock.length; - crcivec.data = (char *) key->keyblock.contents; - ivec = &crcivec; - real_ivec = 0; + crcivec.length = key->keyblock.length; + crcivec.data = (char *) key->keyblock.contents; + ivec = &crcivec; + real_ivec = 0; } else - real_ivec = 1; + real_ivec = 1; if ((ret = ((*(enc->encrypt))(key, ivec, output, output)))) - goto cleanup; + goto cleanup; /* update ivec */ if (real_ivec && ivec != NULL && ivec->length == blocksize) - memcpy(ivec->data, output->data + output->length - blocksize, - blocksize); + memcpy(ivec->data, output->data + output->length - blocksize, + blocksize); cleanup: if (ret) - memset(output->data, 0, output->length); + memset(output->data, 0, output->length); return(ret); } |