"final" is now a reserved word, so change occurrences to "finalize".

This commit is contained in:
Samuel Fredrickson 2014-10-09 00:34:51 -07:00
parent 19eab0e7d7
commit 95b9cf39c9
3 changed files with 12 additions and 12 deletions

View File

@ -56,7 +56,7 @@ impl Hasher {
* Return the digest of all bytes added to this hasher since its last
* initialization
*/
pub fn final(&self) -> Vec<u8> {
pub fn finalize(&self) -> Vec<u8> {
unsafe {
let mut res = Vec::from_elem(self.len, 0u8);
ffi::EVP_DigestFinal(self.ctx, res.as_mut_ptr(), ptr::null_mut());
@ -80,7 +80,7 @@ impl Drop for Hasher {
pub fn hash(t: HashType, data: &[u8]) -> Vec<u8> {
let h = Hasher::new(t);
h.update(data);
h.final()
h.finalize()
}
#[cfg(test)]

View File

@ -48,7 +48,7 @@ impl HMAC {
}
}
pub fn final(&mut self) -> Vec<u8> {
pub fn finalize(&mut self) -> Vec<u8> {
unsafe {
let mut res = Vec::from_elem(self.len, 0u8);
let mut outlen = 0;
@ -94,7 +94,7 @@ mod tests {
for &(ref key, ref data, ref res) in tests.iter() {
let mut hmac = HMAC(MD5, key.as_slice());
hmac.update(data.as_slice());
assert_eq!(hmac.final(), *res);
assert_eq!(hmac.finalize(), *res);
}
}
@ -127,7 +127,7 @@ mod tests {
for &(ref key, ref data, ref res) in tests.iter() {
let mut hmac = HMAC(SHA1, key.as_slice());
hmac.update(data.as_slice());
assert_eq!(hmac.final(), *res);
assert_eq!(hmac.finalize(), *res);
}
}
@ -151,7 +151,7 @@ mod tests {
for (&(ref key, ref data), res) in tests.iter().zip(results.iter()) {
let mut hmac = HMAC(ty, key.as_slice());
hmac.update(data.as_slice());
assert_eq!(hmac.final(), *res);
assert_eq!(hmac.finalize(), *res);
}
}

View File

@ -114,7 +114,7 @@ impl Crypter {
/**
* Finish crypting. Returns the remaining partial block of output, if any.
*/
pub fn final(&self) -> Vec<u8> {
pub fn finalize(&self) -> Vec<u8> {
unsafe {
let mut res = Vec::from_elem(self.blocksize, 0u8);
let mut reslen = self.blocksize as c_int;
@ -145,7 +145,7 @@ pub fn encrypt(t: Type, key: &[u8], iv: Vec<u8>, data: &[u8]) -> Vec<u8> {
let c = Crypter::new(t);
c.init(Encrypt, key, iv);
let mut r = c.update(data);
let rest = c.final();
let rest = c.finalize();
r.extend(rest.into_iter());
r
}
@ -158,7 +158,7 @@ pub fn decrypt(t: Type, key: &[u8], iv: Vec<u8>, data: &[u8]) -> Vec<u8> {
let c = Crypter::new(t);
c.init(Decrypt, key, iv);
let mut r = c.update(data);
let rest = c.final();
let rest = c.finalize();
r.extend(rest.into_iter());
r
}
@ -186,12 +186,12 @@ mod tests {
c.init(super::Encrypt, k0.as_slice(), vec![]);
c.pad(false);
let mut r0 = c.update(p0.as_slice());
r0.extend(c.final().into_iter());
r0.extend(c.finalize().into_iter());
assert!(r0 == c0);
c.init(super::Decrypt, k0.as_slice(), vec![]);
c.pad(false);
let mut p1 = c.update(r0.as_slice());
p1.extend(c.final().into_iter());
p1.extend(c.finalize().into_iter());
assert!(p1 == p0);
}
@ -203,7 +203,7 @@ mod tests {
let expected = ct.from_hex().unwrap().as_slice().to_vec();
let mut computed = cipher.update(pt.from_hex().unwrap().as_slice());
computed.extend(cipher.final().into_iter());
computed.extend(cipher.finalize().into_iter());
if computed != expected {
println!("Computed: {}", computed.as_slice().to_hex());