SecOTRIdentityPriv.h [plain text]
#ifndef _SECOTRIDENTITYPRIV_H_
#include <CoreFoundation/CFRuntime.h>
#include <CoreFoundation/CFData.h>
#include <Security/SecKey.h>
#include <Security/oidsalg.h>
#include <CommonCrypto/CommonDigest.h> // DIGEST_LENGTH
#include <Security/SecOTR.h>
__BEGIN_DECLS
extern CFStringRef sErrorDomain;
#define kPaddingOverhead (2 + 2 * CC_SHA1_DIGEST_LENGTH + 1)
#define kMPIDHashSize CC_SHA1_DIGEST_LENGTH
struct _SecOTRFullIdentity {
CFRuntimeBase _base;
SecKeyRef publicSigningKey;
SecKeyRef privateSigningKey;
uint8_t publicIDHash[kMPIDHashSize];
};
struct _SecOTRPublicIdentity {
CFRuntimeBase _base;
SecKeyRef publicSigningKey;
bool wantsHashes;
uint8_t hash[kMPIDHashSize];
};
enum SecOTRError {
secOTRErrorLocal,
secOTRErrorOSError,
};
const SecAsn1AlgId *kOTRSignatureAlgIDPtr;
void EnsureOTRAlgIDInited(void);
SecOTRFullIdentityRef SecOTRFullIdentityCreateWithSize(CFAllocatorRef allocator, int bits);
bool SecOTRFIAppendSignature(SecOTRFullIdentityRef fullID,
CFDataRef dataToHash,
CFMutableDataRef appendTo,
CFErrorRef *error);
void SecOTRFIAppendPublicHash(SecOTRFullIdentityRef fullID, CFMutableDataRef appendTo);
bool SecOTRFIComparePublicHash(SecOTRFullIdentityRef fullID, const uint8_t hash[kMPIDHashSize]);
size_t SecOTRFISignatureSize(SecOTRFullIdentityRef privateID);
bool SecOTRPIVerifySignature(SecOTRPublicIdentityRef publicID,
const uint8_t *dataToHash, size_t amountToHash,
const uint8_t *signatureStart, size_t signatureSize, CFErrorRef *error);
bool SecOTRPIEqualToBytes(SecOTRPublicIdentityRef id, const uint8_t*bytes, CFIndex size);
bool SecOTRPIEqual(SecOTRPublicIdentityRef left, SecOTRPublicIdentityRef right);
size_t SecOTRPISignatureSize(SecOTRPublicIdentityRef publicID);
void SecOTRPICopyHash(SecOTRPublicIdentityRef publicID, uint8_t hash[kMPIDHashSize]);
void SecOTRPIAppendHash(SecOTRPublicIdentityRef publicID, CFMutableDataRef appendTo);
bool SecOTRPICompareHash(SecOTRPublicIdentityRef publicID, const uint8_t hash[kMPIDHashSize]);
OSStatus insertSize(CFIndex size, uint8_t* here);
OSStatus appendSize(CFIndex size, CFMutableDataRef into);
OSStatus readSize(const uint8_t** data, size_t* limit, uint16_t* size);
OSStatus appendPublicOctets(SecKeyRef fromKey, CFMutableDataRef appendTo);
OSStatus appendPublicOctetsAndSize(SecKeyRef fromKey, CFMutableDataRef appendTo);
OSStatus appendSizeAndData(CFDataRef data, CFMutableDataRef appendTo);
SecKeyRef CreateECPrivateKeyFrom(CFAllocatorRef allocator, const uint8_t** data, size_t* limit);
SecKeyRef CreateECPublicKeyFrom(CFAllocatorRef allocator, const uint8_t** data, size_t* limit);
bool SecOTRCreateError(enum SecOTRError family, CFIndex errorCode, CFStringRef descriptionString, CFErrorRef previousError, CFErrorRef *newError);
__END_DECLS
#endif