Updated to master:
- library stab issues
- deriving -> derive
- {mod} -> {self}
This commit is contained in:
parent
ef8b8f7ead
commit
cf028e971a
|
|
@ -1,13 +1,14 @@
|
|||
use libc::{c_int, c_ulong, c_void};
|
||||
use std::{fmt, ptr};
|
||||
use std::c_str::CString;
|
||||
use std::cmp::Ordering;
|
||||
use std::{fmt, ptr};
|
||||
|
||||
use ffi;
|
||||
use ssl::error::SslError;
|
||||
|
||||
pub struct BigNum(*mut ffi::BIGNUM);
|
||||
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
#[repr(C)]
|
||||
pub enum RNGProperty {
|
||||
MsbMaybeZero = -1,
|
||||
|
|
@ -303,11 +304,11 @@ impl BigNum {
|
|||
unsafe {
|
||||
let res = ffi::BN_ucmp(self.raw(), oth.raw()) as i32;
|
||||
if res < 0 {
|
||||
Less
|
||||
Ordering::Less
|
||||
} else if res > 0 {
|
||||
Greater
|
||||
Ordering::Greater
|
||||
} else {
|
||||
Equal
|
||||
Ordering::Equal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -382,11 +383,11 @@ impl PartialOrd for BigNum {
|
|||
let v = ffi::BN_cmp(self.raw(), oth.raw());
|
||||
let ret =
|
||||
if v == 0 {
|
||||
Equal
|
||||
Ordering::Equal
|
||||
} else if v < 0 {
|
||||
Less
|
||||
Ordering::Less
|
||||
} else {
|
||||
Greater
|
||||
Ordering::Greater
|
||||
};
|
||||
Some(ret)
|
||||
}
|
||||
|
|
@ -404,6 +405,7 @@ impl Drop for BigNum {
|
|||
}
|
||||
|
||||
pub mod unchecked {
|
||||
use std::ops::{Add, Div, Mul, Neg, Rem, Shl, Shr, Sub};
|
||||
use ffi;
|
||||
use super::{BigNum};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::io;
|
|||
|
||||
use ffi;
|
||||
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum HashType {
|
||||
MD5,
|
||||
SHA1,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl Drop for HMAC {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serialize::hex::FromHex;
|
||||
use crypto::hash::HashType::{mod, MD5, SHA1, SHA224, SHA256, SHA384, SHA512};
|
||||
use crypto::hash::HashType::{self, MD5, SHA1, SHA224, SHA256, SHA384, SHA512};
|
||||
use super::HMAC;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crypto::hash::HashType;
|
|||
use ffi;
|
||||
use ssl::error::{SslError, StreamError};
|
||||
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
enum Parts {
|
||||
Neither,
|
||||
Public,
|
||||
|
|
@ -14,7 +14,7 @@ enum Parts {
|
|||
}
|
||||
|
||||
/// Represents a role an asymmetric key might be appropriate for.
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum Role {
|
||||
Encrypt,
|
||||
Decrypt,
|
||||
|
|
@ -23,7 +23,7 @@ pub enum Role {
|
|||
}
|
||||
|
||||
/// Type of encryption padding to use.
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum EncryptionPadding {
|
||||
OAEP,
|
||||
PKCS1v15
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ use libc::{c_int};
|
|||
|
||||
use ffi;
|
||||
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum Mode {
|
||||
Encrypt,
|
||||
Decrypt,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum Type {
|
||||
AES_128_ECB,
|
||||
AES_128_CBC,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::c_str::CString;
|
|||
use ffi;
|
||||
|
||||
/// An SSL error
|
||||
#[deriving(Show, Clone, PartialEq, Eq)]
|
||||
#[derive(Show, Clone, PartialEq, Eq)]
|
||||
pub enum SslError {
|
||||
/// The underlying stream reported an error
|
||||
StreamError(IoError),
|
||||
|
|
@ -37,7 +37,7 @@ impl error::Error for SslError {
|
|||
}
|
||||
|
||||
/// An error from the OpenSSL library
|
||||
#[deriving(Show, Clone, PartialEq, Eq)]
|
||||
#[derive(Show, Clone, PartialEq, Eq)]
|
||||
pub enum OpensslError {
|
||||
/// An unknown error
|
||||
UnknownError {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use libc::{c_int, c_void, c_long};
|
||||
use std::c_str::ToCStr;
|
||||
use std::io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer};
|
||||
use std::mem;
|
||||
use std::num::FromPrimitive;
|
||||
use std::ptr;
|
||||
use std::sync::{Once, ONCE_INIT, Arc};
|
||||
|
||||
|
|
@ -31,9 +33,9 @@ fn init() {
|
|||
}
|
||||
|
||||
/// Determines the SSL method supported
|
||||
#[deriving(Show, Hash, PartialEq, Eq)]
|
||||
#[derive(Show, Hash, PartialEq, Eq)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum SslMethod {
|
||||
#[cfg(feature = "sslv2")]
|
||||
/// Only support the SSLv2 protocol, requires `feature="sslv2"`
|
||||
|
|
@ -69,7 +71,7 @@ impl SslMethod {
|
|||
}
|
||||
|
||||
/// Determines the type of certificate verification used
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
#[repr(i32)]
|
||||
pub enum SslVerifyMode {
|
||||
/// Verify that the server's certificate is trusted
|
||||
|
|
@ -389,7 +391,7 @@ impl Ssl {
|
|||
|
||||
}
|
||||
|
||||
#[deriving(FromPrimitive, Show)]
|
||||
#[derive(FromPrimitive, Show)]
|
||||
#[repr(i32)]
|
||||
enum LibSslError {
|
||||
ErrorNone = ffi::SSL_ERROR_NONE,
|
||||
|
|
@ -404,7 +406,7 @@ enum LibSslError {
|
|||
}
|
||||
|
||||
/// A stream wrapper which handles SSL encryption for an underlying stream.
|
||||
#[deriving(Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct SslStream<S> {
|
||||
stream: S,
|
||||
ssl: Arc<Ssl>,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
use libc::{c_int, c_long, c_uint};
|
||||
use std::c_str::ToCStr;
|
||||
use std::cmp::Ordering;
|
||||
use std::mem;
|
||||
use std::num::SignedInt;
|
||||
use std::ptr;
|
||||
|
|
@ -15,7 +17,7 @@ use ssl::error::{SslError, StreamError};
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
#[repr(i32)]
|
||||
pub enum X509FileType {
|
||||
PEM = ffi::X509_FILETYPE_PEM,
|
||||
|
|
@ -56,7 +58,7 @@ trait AsStr<'a> {
|
|||
fn as_str(&self) -> &'a str;
|
||||
}
|
||||
|
||||
#[deriving(Clone, Copy)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum KeyUsage {
|
||||
DigitalSignature,
|
||||
NonRepudiation,
|
||||
|
|
@ -86,7 +88,7 @@ impl AsStr<'static> for KeyUsage {
|
|||
}
|
||||
|
||||
|
||||
#[deriving(Clone, Copy)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum ExtKeyUsage {
|
||||
ServerAuth,
|
||||
ClientAuth,
|
||||
|
|
@ -395,9 +397,9 @@ impl<'ctx> X509<'ctx> {
|
|||
_ => {
|
||||
let act_len = act_len as uint;
|
||||
match len.cmp(&act_len) {
|
||||
Greater => None,
|
||||
Equal => Some(v),
|
||||
Less => panic!("Fingerprint buffer was corrupted!")
|
||||
Ordering::Greater => None,
|
||||
Ordering::Equal => Some(v),
|
||||
Ordering::Less => panic!("Fingerprint buffer was corrupted!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -432,7 +434,7 @@ pub struct X509Name<'x> {
|
|||
|
||||
macro_rules! make_validation_error(
|
||||
($ok_val:ident, $($name:ident = $val:ident,)+) => (
|
||||
#[deriving(Copy)]
|
||||
#[derive(Copy)]
|
||||
pub enum X509ValidationError {
|
||||
$($name,)+
|
||||
X509UnknownError(c_int)
|
||||
|
|
|
|||
Loading…
Reference in New Issue