]>
git.saurik.com Git - apple/security.git/blob - sec/Security/SecOTRMath.h
3 // libsecurity_libSecOTR
5 // Created by Mitch Adler on 1/28/11.
6 // Copyright 2011 Apple Inc. All rights reserved.
10 #define _SECOTRMATH_H_
12 #include <CoreFoundation/CFBase.h>
14 #include <corecrypto/ccn.h>
15 #include <corecrypto/ccaes.h>
16 #include <corecrypto/ccmode.h>
18 #define kOTRAuthKeyBytes 16
19 #define kOTRAuthMACKeyBytes 32
21 #define kOTRMessageKeyBytes 16
22 #define kOTRMessageMacKeyBytes 20
24 #define kExponentiationBits 1536
25 #define kExponentiationUnits ccn_nof(kExponentiationBits)
26 #define kExponentiationBytes ((kExponentiationBits+7)/8)
28 #define kSHA256HMAC160Bits 160
29 #define kSHA256HMAC160Bytes (kSHA256HMAC160Bits/8)
31 // Result and exponent are expected to be kExponentiationUnits big.
32 void OTRExponentiate(cc_unit
* res
, const cc_unit
* base
, const cc_unit
* exponent
);
33 void OTRGroupExponentiate(cc_unit
* result
, const cc_unit
* exponent
);
35 OSStatus
GetRandomBytesInLSBs(size_t bytesOfRandomness
, size_t n
, cc_unit
* place
);
36 OSStatus
FillWithRandomBytes(size_t n
, cc_unit
* place
);
48 void DeriveOTR256BitsFromS(KeyType whichKey
, size_t sSize
, const cc_unit
* s
, size_t keySize
, uint8_t* key
);
49 void DeriveOTR128BitPairFromS(KeyType whichHalf
, size_t sSize
, const cc_unit
* s
,
50 size_t firstKeySize
, uint8_t* firstKey
,
51 size_t secondKeySize
, uint8_t* secondKey
);
52 void DeriveOTR64BitsFromS(KeyType whichKey
, size_t sSize
, const cc_unit
* s
,
53 size_t firstKeySize
, uint8_t* firstKey
);
56 void AES_CTR_HighHalf_Transform(size_t keySize
, const uint8_t* key
,
58 size_t howMuch
, const uint8_t* from
,
61 void AES_CTR_IV0_Transform(size_t keySize
, const uint8_t* key
,
62 size_t howMuch
, const uint8_t* from
,