#ifndef _SECOTRSESSION_H_
#define _SECOTRSESSION_H_
#include <CoreFoundation/CFBase.h>
#include <CoreFoundation/CFData.h>
#include <Security/SecOTR.h>
__BEGIN_DECLS
enum SecOTRSMessageKind {
kOTRNegotiationPacket,
kOTRDataPacket,
kOTRUnknownPacket
};
enum SecOTRCreateFlags {
kSecOTRSendTextMessages = 1 << 0, kSecOTRUseAppleCustomMessageFormat = 1 << 1, kSecOTRIncludeHashesInMessages = 1 << 2,
kSecOTRSlowRoll = 1 << 3,
};
typedef struct _SecOTRSession* SecOTRSessionRef;
SecOTRSessionRef SecOTRSessionCreateFromID(CFAllocatorRef allocator,
SecOTRFullIdentityRef myID,
SecOTRPublicIdentityRef theirID);
SecOTRSessionRef SecOTRSessionCreateFromIDAndFlags(CFAllocatorRef allocator,
SecOTRFullIdentityRef myID,
SecOTRPublicIdentityRef theirID,
uint32_t flags);
SecOTRSessionRef SecOTRSessionCreateFromData(CFAllocatorRef allocator, CFDataRef data);
void SecOTRSessionReset(SecOTRSessionRef session);
OSStatus SecOTRSAppendSerialization(SecOTRSessionRef publicID, CFMutableDataRef serializeInto);
OSStatus SecOTRSAppendStartPacket(SecOTRSessionRef session, CFMutableDataRef appendInitiatePacket);
OSStatus SecOTRSAppendRestartPacket(SecOTRSessionRef session, CFMutableDataRef appendPacket);
OSStatus SecOTRSProcessPacket(SecOTRSessionRef session,
CFDataRef incomingPacket,
CFMutableDataRef negotiationResponse);
bool SecOTRSIsForKeys(SecOTRSessionRef session, SecKeyRef myPublic, SecKeyRef theirPublic);
bool SecOTRSGetIsReadyForMessages(SecOTRSessionRef session);
bool SecOTRSGetIsIdle(SecOTRSessionRef session);
enum SecOTRSMessageKind SecOTRSGetMessageKind(SecOTRSessionRef session, CFDataRef incomingPacket);
void SecOTRSPrecalculateKeys(SecOTRSessionRef session);
OSStatus SecOTRSSignAndProtectMessage(SecOTRSessionRef session,
CFDataRef sourceMessage,
CFMutableDataRef protectedMessage);
OSStatus SecOTRSVerifyAndExposeMessage(SecOTRSessionRef session,
CFDataRef incomingMessage,
CFMutableDataRef exposedMessageContents);
const char *SecOTRPacketTypeString(CFDataRef message);
CFDataRef SecOTRSessionCreateRemote(CFDataRef publicPeerId, CFErrorRef *error);
bool SecOTRSessionProcessPacketRemote(CFDataRef sessionData, CFDataRef inputPacket, CFDataRef* outputSessionData, CFDataRef* outputPacket, bool *readyForMessages, CFErrorRef *error);
bool SecOTRSessionIsSessionInAwaitingState(SecOTRSessionRef session);
__END_DECLS
#endif