Mercurial > pidgin
diff src/protocols/sametime/meanwhile/mw_cipher.h @ 11943:0110fc7c6a8a
[gaim-migrate @ 14234]
Bringing things up to date with the last Meanwhile release, 0.5.0 and the last
gaim-meanwhile plugin release, 1.2.5 (which should be the last plugin release
against oldstatus, if all goes well with HEAD and no major bugs crop up)
It builds, so that's a start. The status bits that have been empty since the
first import of the sametime stuff are still empty, but I'm going to try and
fill those in tomorrow. I've decided to try and start using HEAD actively, to
encourage me to get this freaking prpl fully functional.
committer: Tailor Script <tailor@pidgin.im>
| author | Christopher O'Brien <siege@pidgin.im> |
|---|---|
| date | Wed, 02 Nov 2005 03:39:03 +0000 |
| parents | 3ef77720e577 |
| children | 2edf5dc1b2ea |
line wrap: on
line diff
--- a/src/protocols/sametime/meanwhile/mw_cipher.h Wed Nov 02 03:31:38 2005 +0000 +++ b/src/protocols/sametime/meanwhile/mw_cipher.h Wed Nov 02 03:39:03 2005 +0000 @@ -31,8 +31,8 @@ struct mwSession; - -/** Common cipher types */ +/** @enum mwCipherType + Common cipher types */ enum mwCipherType { mwCipher_RC2_40 = 0x0000, mwCipher_RC2_128 = 0x0001, @@ -50,7 +50,10 @@ /** Generate a descriptor for use in a channel create message to - indicate the availability of this cipher */ + indicate the availability of this cipher + + @todo remove for 1.0 +*/ typedef struct mwEncryptItem *(*mwCipherDescriptor) (struct mwCipherInstance *instance); @@ -82,13 +85,15 @@ @see mwCipher_newInstance */ mwCipherInstantiator new_instance; - /** @see mwCipher_newItem */ + /** @see mwCipher_newItem + @todo remove for 1.0 + */ mwCipherDescriptor new_item; void (*offered)(struct mwCipherInstance *ci, struct mwEncryptItem *item); - void (*offer)(struct mwCipherInstance *ci); + struct mwEncryptItem *(*offer)(struct mwCipherInstance *ci); void (*accepted)(struct mwCipherInstance *ci, struct mwEncryptItem *item); - void (*accept)(struct mwCipherInstance *ci); + struct mwEncryptItem *(*accept)(struct mwCipherInstance *ci); mwCipherProcessor encrypt; /**< @see mwCipherInstance_encrypt */ mwCipherProcessor decrypt; /**< @see mwCipherInstance_decrypt */ @@ -121,10 +126,7 @@ struct mwCipher *mwCipher_new_RC2_40(struct mwSession *s); -#if 0 -/* @todo write this */ -struct mwCipher *mwCipher_new_DH_RC2_128(struct mwSession *s); -#endif +struct mwCipher *mwCipher_new_RC2_128(struct mwSession *s); struct mwSession *mwCipher_getSession(struct mwCipher *cipher); @@ -151,6 +153,10 @@ struct mwCipher *mwCipherInstance_getCipher(struct mwCipherInstance *ci); +/** + Deprecated in favor of the methods mwCipherInstance_offer and + mwCipherInstance_accept +*/ struct mwEncryptItem *mwCipherInstance_newItem(struct mwCipherInstance *ci); @@ -160,7 +166,8 @@ /** Offer a cipher */ -void mwCipherInstance_offer(struct mwCipherInstance *ci); +struct mwEncryptItem * +mwCipherInstance_offer(struct mwCipherInstance *ci); /** Indicates an offered cipher has been accepted */ @@ -169,7 +176,8 @@ /** Accept a cipher offered to our channel */ -void mwCipherInstance_accept(struct mwCipherInstance *ci); +struct mwEncryptItem * +mwCipherInstance_accept(struct mwCipherInstance *ci); /** encrypt data */ @@ -189,16 +197,8 @@ /** @section General Cipher Functions - This set of functions is a broken sort of RC2 implementation. But it - works with sametime, so we're all happy, right? Primary change to - functionality appears in the mwKeyExpand function. Hypothetically, - using a key expanded here (but breaking it into a 128-char array - rather than 64 ints), one could pass it at that length to openssl - and no further key expansion would occur. - - I'm not certain if replacing this with a wrapper for calls to some - other crypto library is a good idea or not. Proven software versus - added dependencies... + These functions are reused where encryption is necessary outside of + a channel (eg. session authentication) */ /* @{ */ @@ -207,10 +207,10 @@ @param keylen count of bytes to write into key @param key buffer to write keys into */ -void rand_key(char *key, gsize keylen); +void mwKeyRandom(char *key, gsize keylen); -/** Setup an Initialization Vector */ +/** Setup an Initialization Vector. IV must be at least 8 bytes */ void mwIV_init(char *iv); @@ -244,6 +244,47 @@ /* @} */ +/** + @section Diffie-Hellman Functions + + These functions are reused where DH Key negotiation is necessary + outside of a channel (eg. session authentication). You'll need to + include <gmp.h> in order to use these functions. +*/ +/* @{ */ +#ifdef __GMP_H__ + + +/** initialize and set a big integer to the Sametime Prime value */ +void mwInitDHPrime(mpz_t z); + + +/** initialize and set a big integer to the Sametime Base value */ +void mwInitDHBase(mpz_t z); + + +/** sets private to a randomly generated value, and calculates public + using the Sametime Prime and Base */ +void mwDHRandKeypair(mpz_t private, mpz_t public); + + +/** sets the shared key value based on the remote and private keys, + using the Sametime Prime and Base */ +void mwDHCalculateShared(mpz_t shared, mpz_t remote, mpz_t private); + + +/** Import a DH key from an opaque */ +void mwDHImportKey(mpz_t key, struct mwOpaque *o); + + +/** Export a DH key into an opaque */ +void mwDHExportKey(mpz_t key, struct mwOpaque *o); + + +#endif +/* @} */ + + #endif
