]> git.saurik.com Git - apple/security.git/blob - sec/Security/SecOTRSessionPriv.h
Security-55471.14.8.tar.gz
[apple/security.git] / sec / Security / SecOTRSessionPriv.h
1 //
2 // SecOTRSessionPriv.h
3 // libsecurity_libSecOTR
4 //
5 // Created by Mitch Adler on 2/23/11.
6 // Copyright 2011 Apple Inc. All rights reserved.
7 //
8
9 #ifndef _SECOTRSESSIONPRIV_H_
10 #define _SECOTRSESSIONPRIV_H_
11
12 #include <CoreFoundation/CFBase.h>
13 #include <CoreFoundation/CFRuntime.h>
14
15 #include <Security/SecOTR.h>
16 #include <corecrypto/ccn.h>
17 #include <corecrypto/ccmode.h>
18 #include <corecrypto/ccsha1.h>
19
20 #include <CommonCrypto/CommonDigest.h>
21
22 #include <dispatch/dispatch.h>
23
24 #include <Security/SecOTRMath.h>
25 #include <Security/SecOTRDHKey.h>
26
27 __BEGIN_DECLS
28
29 typedef enum {
30 kIdle,
31 kAwaitingDHKey,
32 kAwaitingRevealSignature,
33 kAwaitingSignature,
34 kDone
35 } SecOTRAuthState;
36
37 struct _SecOTRCacheElement {
38 SecOTRFullDHKeyRef _fullKey;
39 uint8_t _fullKeyHash[CCSHA1_OUTPUT_SIZE];
40 SecOTRPublicDHKeyRef _publicKey;
41 uint8_t _publicKeyHash[CCSHA1_OUTPUT_SIZE];
42
43 uint8_t _sendMacKey[kOTRMessageMacKeyBytes];
44 uint8_t _sendEncryptionKey[kOTRMessageKeyBytes];
45
46 uint8_t _receiveMacKey[kOTRMessageMacKeyBytes];
47 uint8_t _receiveEncryptionKey[kOTRMessageKeyBytes];
48
49 uint64_t _counter;
50 uint64_t _theirCounter;
51
52 };
53 typedef struct _SecOTRCacheElement SecOTRCacheElement;
54
55 #define kOTRKeyCacheSize 4
56
57 struct _SecOTRSession {
58 CFRuntimeBase _base;
59
60 SecOTRAuthState _state;
61
62 SecOTRFullIdentityRef _me;
63 SecOTRPublicIdentityRef _them;
64
65 uint8_t _r[kOTRAuthKeyBytes];
66
67 CFDataRef _receivedDHMessage;
68 CFDataRef _receivedDHKeyMessage;
69
70 uint32_t _keyID;
71 SecOTRFullDHKeyRef _myKey;
72 SecOTRFullDHKeyRef _myNextKey;
73
74 uint32_t _theirKeyID;
75 SecOTRPublicDHKeyRef _theirPreviousKey;
76 SecOTRPublicDHKeyRef _theirKey;
77
78 CFMutableDataRef _macKeysToExpose;
79
80 dispatch_queue_t _queue;
81
82 SecOTRCacheElement _keyCache[kOTRKeyCacheSize];
83
84 bool _textOutput;
85 };
86
87 void SecOTRGetIncomingBytes(CFDataRef incomingMessage, CFMutableDataRef decodedBytes);
88 void SecOTRPrepareOutgoingBytes(CFMutableDataRef destinationMessage, CFMutableDataRef protectedMessage);
89
90 __END_DECLS
91
92 #endif