diff options
-rw-r--r-- | cryptography/hazmat/bindings/commoncrypto/common_cryptor.py | 94 |
1 files changed, 29 insertions, 65 deletions
diff --git a/cryptography/hazmat/bindings/commoncrypto/common_cryptor.py b/cryptography/hazmat/bindings/commoncrypto/common_cryptor.py index 69edf1e7..8783ece8 100644 --- a/cryptography/hazmat/bindings/commoncrypto/common_cryptor.py +++ b/cryptography/hazmat/bindings/commoncrypto/common_cryptor.py @@ -27,13 +27,13 @@ enum { }; typedef uint32_t CCAlgorithm; enum { - kCCSuccess = 0, - kCCParamError = -4300, - kCCBufferTooSmall = -4301, - kCCMemoryFailure = -4302, - kCCAlignmentError = -4303, - kCCDecodeError = -4304, - kCCUnimplemented = -4305 + kCCSuccess = 0, + kCCParamError = -4300, + kCCBufferTooSmall = -4301, + kCCMemoryFailure = -4302, + kCCAlignmentError = -4303, + kCCDecodeError = -4304, + kCCUnimplemented = -4305 }; typedef int32_t CCCryptorStatus; typedef uint32_t CCOptions; @@ -52,74 +52,38 @@ enum { typedef uint32_t CCModeOptions; enum { - kCCModeECB = 1, - kCCModeCBC = 2, - kCCModeCFB = 3, - kCCModeCTR = 4, - kCCModeF8 = 5, // Unimplemented for now (not included) - kCCModeLRW = 6, // Unimplemented for now (not included) - kCCModeOFB = 7, - kCCModeXTS = 8, - kCCModeRC4 = 9, - kCCModeCFB8 = 10, + kCCModeECB = 1, + kCCModeCBC = 2, + kCCModeCFB = 3, + kCCModeCTR = 4, + kCCModeF8 = 5, + kCCModeLRW = 6, + kCCModeOFB = 7, + kCCModeXTS = 8, + kCCModeRC4 = 9, + kCCModeCFB8 = 10, }; typedef uint32_t CCMode; enum { - ccNoPadding = 0, - ccPKCS7Padding = 1, + ccNoPadding = 0, + ccPKCS7Padding = 1, }; typedef uint32_t CCPadding; """ FUNCTIONS = """ -CCCryptorStatus CCCryptorCreateWithMode( - CCOperation, /* kCCEncrypt, kCCEncrypt */ - CCMode, - CCAlgorithm, - CCPadding, - const void *, /* optional initialization vector */ - const void *, /* raw key material */ - size_t, - const void *, /* raw tweak material */ - size_t, - int, /* number of rounds. 0 == default */ - CCModeOptions, - CCCryptorRef *); /* RETURNED */ +CCCryptorStatus CCCryptorCreateWithMode(CCOperation, CCMode, CCAlgorithm, + CCPadding, const void *, const void *, + size_t, const void *, size_t, int, + CCModeOptions, CCCryptorRef *); -CCCryptorStatus CCCryptorCreate( - CCOperation, /* kCCEncrypt, etc. */ - CCAlgorithm, /* kCCAlgorithmDES, etc. */ - CCOptions, /* kCCOptionPKCS7Padding, etc. */ - const void *, /* raw key material */ - size_t, - const void *, /* optional initialization vector */ - CCCryptorRef *); /* RETURNED */ -CCCryptorStatus CCCryptorUpdate( - CCCryptorRef, - const void *, - size_t, - void *, /* data RETURNED here */ - size_t, - size_t *); /* number of bytes written */ -CCCryptorStatus CCCryptorFinal( - CCCryptorRef, - void *, - size_t, - size_t *); /* number of bytes written */ +CCCryptorStatus CCCryptorCreate(CCOperation, CCAlgorithm, CCOptions, + const void *, size_t, const void *, + CCCryptorRef *); +CCCryptorStatus CCCryptorUpdate(CCCryptorRef, const void *, size_t, void *, + size_t, size_t *); +CCCryptorStatus CCCryptorFinal(CCCryptorRef, void *, size_t, size_t *); CCCryptorStatus CCCryptorRelease(CCCryptorRef); - -/* GCM functions, 10.8+ iOS 5+ */ -enum { - kCCModeGCM = 11 -}; -CCCryptorStatus CCCryptorGCMAddIV(CCCryptorRef, const void *, size_t); -CCCryptorStatus CCCryptorGCMAddAAD(CCCryptorRef, const void *, size_t); -CCCryptorStatus CCCryptorGCMEncrypt(CCCryptorRef, const void *, size_t, - void *); -CCCryptorStatus CCCryptorGCMDecrypt(CCCryptorRef, const void *, size_t, - void *); -CCCryptorStatus CCCryptorGCMFinal(CCCryptorRef, const void *, size_t *); -CCCryptorStatus CCCryptorGCMReset(CCCryptorRef); """ MACROS = """ |