3 // libsecurity_libSecOTR
5 // Created by Mitch Adler on 2/23/11.
6 // Copyright 2011 Apple Inc. All rights reserved.
9 #ifndef _SECOTRSESSIONPRIV_H_
10 #define _SECOTRSESSIONPRIV_H_
12 #include <CoreFoundation/CFBase.h>
13 #include <CoreFoundation/CFRuntime.h>
15 #include <Security/SecOTR.h>
16 #include <corecrypto/ccn.h>
17 #include <corecrypto/ccmode.h>
18 #include <corecrypto/ccsha1.h>
20 #include <CommonCrypto/CommonDigest.h>
22 #include <dispatch/dispatch.h>
24 #include <Security/SecOTRMath.h>
25 #include <Security/SecOTRDHKey.h>
32 kAwaitingRevealSignature
,
37 struct _SecOTRCacheElement
{
38 SecOTRFullDHKeyRef _fullKey
;
39 uint8_t _fullKeyHash
[CCSHA1_OUTPUT_SIZE
];
40 SecOTRPublicDHKeyRef _publicKey
;
41 uint8_t _publicKeyHash
[CCSHA1_OUTPUT_SIZE
];
43 uint8_t _sendMacKey
[kOTRMessageMacKeyBytes
];
44 uint8_t _sendEncryptionKey
[kOTRMessageKeyBytes
];
46 uint8_t _receiveMacKey
[kOTRMessageMacKeyBytes
];
47 uint8_t _receiveEncryptionKey
[kOTRMessageKeyBytes
];
50 uint64_t _theirCounter
;
53 typedef struct _SecOTRCacheElement SecOTRCacheElement
;
55 #define kOTRKeyCacheSize 4
57 struct _SecOTRSession
{
60 SecOTRAuthState _state
;
62 SecOTRFullIdentityRef _me
;
63 SecOTRPublicIdentityRef _them
;
65 uint8_t _r
[kOTRAuthKeyBytes
];
67 CFDataRef _receivedDHMessage
;
68 CFDataRef _receivedDHKeyMessage
;
71 SecOTRFullDHKeyRef _myKey
;
72 SecOTRFullDHKeyRef _myNextKey
;
75 SecOTRPublicDHKeyRef _theirPreviousKey
;
76 SecOTRPublicDHKeyRef _theirKey
;
78 CFMutableDataRef _macKeysToExpose
;
80 dispatch_queue_t _queue
;
82 SecOTRCacheElement _keyCache
[kOTRKeyCacheSize
];
87 void SecOTRGetIncomingBytes(CFDataRef incomingMessage
, CFMutableDataRef decodedBytes
);
88 void SecOTRPrepareOutgoingBytes(CFMutableDataRef destinationMessage
, CFMutableDataRef protectedMessage
);