From: John Kohl Date: Fri, 19 Oct 1990 09:48:12 +0000 (+0000) Subject: code rearrangement for const * stuff; make the _f functions static X-Git-Tag: krb5-1.0-alpha2~131 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c6947463aa93d9ecba6ec64fed08635f0dda41af;p=krb5.git code rearrangement for const * stuff; make the _f functions static git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1280 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/crypto/des/enc_dec.c b/src/lib/crypto/des/enc_dec.c index c236258be..d8799afb9 100644 --- a/src/lib/crypto/des/enc_dec.c +++ b/src/lib/crypto/des/enc_dec.c @@ -40,15 +40,53 @@ static char rcsid_enc_dec_c[] = extern int mit_des_debug; #endif +/* + encrypts "size" bytes at "in", storing result in "out". + "eblock" points to an encrypt block which has been initialized + by process_key(). -krb5_error_code mit_des_encrypt_func(DECLARG(krb5_pointer, in), + "out" must be preallocated by the caller to contain sufficient + storage to hold the output; the macro krb5_encrypt_size() can + be used to compute this size. + + returns: errors +*/ +static krb5_error_code +mit_des_encrypt_f(DECLARG(krb5_const_pointer, in), + DECLARG(krb5_pointer, out), + DECLARG(const_size_t, size), + DECLARG(krb5_encrypt_block *, key), + DECLARG(krb5_pointer, ivec)) +OLDDECLARG(krb5_const_pointer, in) +OLDDECLARG(krb5_pointer, out) +OLDDECLARG(const size_t, size) +OLDDECLARG(krb5_encrypt_block *, key) +OLDDECLARG(krb5_pointer, ivec) +{ + krb5_octet *iv; + + if ( ivec == 0 ) + iv = key->key->contents; + else + iv = (krb5_octet *)ivec; + + /* XXX should check that key sched is valid here? */ + return (mit_des_cbc_encrypt((krb5_octet *)in, + (krb5_octet *)out, + size, + (struct mit_des_ks_struct *)key->priv, + iv, + MIT_DES_ENCRYPT)); +} + +krb5_error_code mit_des_encrypt_func(DECLARG(krb5_const_pointer, in), DECLARG(krb5_pointer, out), - DECLARG(size_t, size), + DECLARG(const size_t, size), DECLARG(krb5_encrypt_block *, key), DECLARG(krb5_pointer, ivec)) -OLDDECLARG(krb5_pointer, in) +OLDDECLARG(krb5_const_pointer, in) OLDDECLARG(krb5_pointer, out) -OLDDECLARG(size_t, size) +OLDDECLARG(const size_t, size) OLDDECLARG(krb5_encrypt_block *, key) OLDDECLARG(krb5_pointer, ivec) { @@ -56,7 +94,7 @@ OLDDECLARG(krb5_pointer, ivec) krb5_octet contents[CRC32_CKSUM_LENGTH]; char *p, *endinput; int sumsize; - krb5_error_code retval, mit_des_encrypt_f(); + krb5_error_code retval; /* if ( size < sizeof(mit_des_cblock) ) return KRB5_BAD_MSIZE; */ @@ -84,51 +122,54 @@ OLDDECLARG(krb5_pointer, ivec) } /* - encrypts "size" bytes at "in", storing result in "out". + + decrypts "size" bytes at "in", storing result in "out". "eblock" points to an encrypt block which has been initialized by process_key(). "out" must be preallocated by the caller to contain sufficient - storage to hold the output; the macro krb5_encrypt_size() can - be used to compute this size. - + storage to hold the output; this is guaranteed to be no more than + the input size. + returns: errors -*/ -krb5_error_code mit_des_encrypt_f(DECLARG(krb5_pointer, in), - DECLARG(krb5_pointer, out), - DECLARG(size_t, size), - DECLARG(krb5_encrypt_block *, key), - DECLARG(krb5_pointer, ivec)) -OLDDECLARG(krb5_pointer, in) + + */ +static krb5_error_code +mit_des_decrypt_f(DECLARG(krb5_const_pointer, in), + DECLARG(krb5_pointer, out), + DECLARG(const size_t, size), + DECLARG(krb5_encrypt_block *, key), + DECLARG(krb5_pointer, ivec)) +OLDDECLARG(krb5_const_pointer, in) OLDDECLARG(krb5_pointer, out) -OLDDECLARG(size_t, size) +OLDDECLARG(const size_t, size) OLDDECLARG(krb5_encrypt_block *, key) OLDDECLARG(krb5_pointer, ivec) { krb5_octet *iv; - + if ( ivec == 0 ) iv = key->key->contents; else iv = (krb5_octet *)ivec; /* XXX should check that key sched is valid here? */ - return (mit_des_cbc_encrypt((krb5_octet *)in, - (krb5_octet *)out, - size, - (struct mit_des_ks_struct *)key->priv, - iv, - MIT_DES_ENCRYPT)); + return (mit_des_cbc_encrypt ((krb5_octet *)in, + (krb5_octet *)out, + size, + (struct mit_des_ks_struct *)key->priv, + iv, + MIT_DES_DECRYPT)); } -krb5_error_code mit_des_decrypt_func(DECLARG(krb5_pointer, in), +krb5_error_code mit_des_decrypt_func(DECLARG(krb5_const_pointer, in), DECLARG(krb5_pointer, out), - DECLARG(size_t, size), + DECLARG(const size_t, size), DECLARG(krb5_encrypt_block *, key), DECLARG(krb5_pointer, ivec)) -OLDDECLARG(krb5_pointer, in) +OLDDECLARG(krb5_const_pointer, in) OLDDECLARG(krb5_pointer, out) -OLDDECLARG(size_t, size) +OLDDECLARG(const size_t, size) OLDDECLARG(krb5_encrypt_block *, key) OLDDECLARG(krb5_pointer, ivec) { @@ -136,7 +177,7 @@ OLDDECLARG(krb5_pointer, ivec) krb5_octet contents_prd[CRC32_CKSUM_LENGTH]; krb5_octet contents_get[CRC32_CKSUM_LENGTH]; char *p; - krb5_error_code retval, mit_des_decrypt_f(); + krb5_error_code retval; if ( size < sizeof(mit_des_cblock) ) return KRB5_BAD_MSIZE; @@ -162,46 +203,6 @@ OLDDECLARG(krb5_pointer, ivec) return 0; } - -/* - - decrypts "size" bytes at "in", storing result in "out". - "eblock" points to an encrypt block which has been initialized - by process_key(). - - "out" must be preallocated by the caller to contain sufficient - storage to hold the output; this is guaranteed to be no more than - the input size. - - returns: errors - - */ -krb5_error_code mit_des_decrypt_f(DECLARG(krb5_pointer, in), - DECLARG(krb5_pointer, out), - DECLARG(size_t, size), - DECLARG(krb5_encrypt_block *, key), - DECLARG(krb5_pointer, ivec)) -OLDDECLARG(krb5_pointer, in) -OLDDECLARG(krb5_pointer, out) -OLDDECLARG(size_t, size) -OLDDECLARG(krb5_encrypt_block *, key) -OLDDECLARG(krb5_pointer, ivec) -{ - krb5_octet *iv; - - if ( ivec == 0 ) - iv = key->key->contents; - else - iv = (krb5_octet *)ivec; - - /* XXX should check that key sched is valid here? */ - return (mit_des_cbc_encrypt ((krb5_octet *)in, - (krb5_octet *)out, - size, - (struct mit_des_ks_struct *)key->priv, - iv, - MIT_DES_DECRYPT)); -} /* * This routine performs DES cipher-block-chaining operation, either * encrypting from cleartext to ciphertext, if encrypt != 0 or