3 // libsecurity_libSecOTR
5 // Created by Mitch Adler on 3/2/11.
6 // Copyright 2011 Apple Inc. All rights reserved.
8 #ifndef _SECOTRDHKEY_H_
9 #define _SECOTRDHKEY_H_
11 #include <CoreFoundation/CFBase.h>
12 #include <CoreFoundation/CFData.h>
13 #include <corecrypto/ccn.h>
17 typedef struct _SecOTRFullDHKey
* SecOTRFullDHKeyRef
;
18 typedef struct _SecOTRPublicDHKey
* SecOTRPublicDHKeyRef
;
20 SecOTRFullDHKeyRef
SecOTRFullDHKCreate(CFAllocatorRef allocator
);
21 SecOTRFullDHKeyRef
SecOTRFullDHKCreateFromBytes(CFAllocatorRef allocator
, const uint8_t**bytes
, size_t*size
);
23 void SecFDHKNewKey(SecOTRFullDHKeyRef key
);
24 void SecFDHKAppendSerialization(SecOTRFullDHKeyRef fullKey
, CFMutableDataRef appendTo
);
25 void SecFDHKAppendPublicSerialization(SecOTRFullDHKeyRef fullKey
, CFMutableDataRef appendTo
);
26 uint8_t* SecFDHKGetHash(SecOTRFullDHKeyRef pubKey
);
29 SecOTRPublicDHKeyRef
SecOTRPublicDHKCreateFromFullKey(CFAllocatorRef allocator
, SecOTRFullDHKeyRef full
);
30 SecOTRPublicDHKeyRef
SecOTRPublicDHKCreateFromSerialization(CFAllocatorRef allocator
, const uint8_t**bytes
, size_t*size
);
31 SecOTRPublicDHKeyRef
SecOTRPublicDHKCreateFromBytes(CFAllocatorRef allocator
, const uint8_t** bytes
, size_t *size
);
33 void SecPDHKAppendSerialization(SecOTRPublicDHKeyRef pubKey
, CFMutableDataRef appendTo
);
34 uint8_t* SecPDHKGetHash(SecOTRPublicDHKeyRef pubKey
);
36 void SecPDHKeyGenerateS(SecOTRFullDHKeyRef myKey
, SecOTRPublicDHKeyRef theirKey
, cc_unit
* s
);
38 bool SecDHKIsGreater(SecOTRFullDHKeyRef myKey
, SecOTRPublicDHKeyRef theirKey
);
40 void SecOTRDHKGenerateOTRKeys(SecOTRFullDHKeyRef myKey
, SecOTRPublicDHKeyRef theirKey
,
41 uint8_t* sendMessageKey
, uint8_t* sendMacKey
,
42 uint8_t* receiveMessageKey
, uint8_t* receiveMacKey
);