[OTR-dev] A C# lib
alex323
alex323 at gmail.com
Sat Jan 15 13:19:20 EST 2005
Hmmm.. i'm having some problems. My friend keeps telling me that there
was a malformed key exchange. Maybe one of you can look at what my
program is generating? Thanks
To reply to a key exchange (reply=1):
?OTR:AAEKAG8IXHYaE01IBR0bB31gHgFwM1QlXUgUCgh3InJIKj5PKQkSLHgiDFwTeBkhbTUWUk0sZ2FJWlAyfnwySjdWIHYjRmxgEAxxU1NbJ1JIX0w2I2guZxFmGCF5R2AQQUgCSi88E2NeWRtcfRMtfVgJVWkbdzJ+GjR5DkkbeGFpfidvBgYPAGl/NARaACNyXz5AOhQxOSM4MwNOGncXCGE9LUM+djx3IR0IdxMaLHFvdCABDT9zJk1IfAMkZT1QYQkhGjMPJEEcegUcG2RKKDpicnMFHlsKVmdAIXk+aFcvTHZrPVV4b28lexFiKUMsJxwgSzdvfWM3IztVbXEiZRM9YA5aCA0PMy1QLFN7aB8TRR5xQGpmJzwRLEE3AggMOn1qcFNuXnkeUxdjQ1FVTWAQNHsPAz8xKkQjRCQYWEhCAzlNU01DJDVXGWMPNhpYFwp0JwlWQDITLwl/BiYCfjc6Fl04Th96eDEkWW1pICYeRUs+JV0ANip3FXJZBQ9DPzsLZBN+YzhUHxplHXlcFi0TTyllPGg0UxYGE0c3bwFrVVUheFNDE2VDOSxKF2gnAgpvCWU5E3BZTAIQWEwEMSp6ey4VBjcpOQ8+QhgFUFNCe0FHFHFkFWJsBVlEPVA1BksdLBc5Kj9pJXltNQ9VeDURPSAvSGY/PE50EE94ZlkPMjxdX1hjFyZaZko/cyUoIWJ6PRFqEjYRQndoNwcwYklGJg12TXlcG11ieBBAEFZQfwlGLGUANgBIG0sZQSs1ZHRhaiJsRFpnSFo/BlIsThl4SQp/FQhvAhAnSng1b3wcfQ40VyQDF1Q3UCkufnUZInVEeVtrWQwgWBQCL3ViaQ==.
To send a key (reply=0):
?OTR:AAEKAR5AVE8xfUsjSCk+bVcZU146PA1MGzYuSDwaJz16TiB0J0prS2tdPDcJPlM8FhRHGGlqVmJWWFxaWwYNOgsyfzZvLU1aWEV2N0xHQVEnCiZ3QA9BehtKTBVkQScZG21ucyBmXUEfSjcyOisEU0IYJx5gckltGW98AzxZfRBULRcTIDAzT2MQKTBmcg8MRTt/QG10TWlQdBoUdx8oZgoeXRkifhZEL0sZUzAiT3U6DnUDR3ErUjpzUXUueWdgLixmLSsYIh0WSiR0FhR2VClxMVQlBztRelk2Mk1XSwcbI2o2fEYYXn9/VntZZCF2XAQbFjskbnlRKTt2Zzs7alxxCn9vSTUGBTYWDTYTEHlQS0ZUJxE8JScpK0QyYGhEdCVfRAg2EBNNaR8KEHduTkZSWg8edVpMRXopZRgzK3dnQRgQPG8oJxR0cXsBfSpyORhzen8xEQl7VnhvIWRGYj92bnBfcGY8PwwySAodEy8iRw4mcw9aIm84fT5ABHcoIxoTYiViBENCGjtAJ0FaMRI0Qn4IfH8IeiQPRns+fQx8LlJYUgsrOzhSei1XYRBmBAluaBJsJWkMZFgDBklKTl9+ND8cYzsqcFl7WURZF21ESGEdHgE0J0tfMGBVCGBEREIgPjBvJ2ZNexJ6dDkAfQpVbnkbJR5DGR00Ei8sUgwACxJNSEwRIF1gSgEuKUlRTGxrM09/PGt6XkwebTUsSngzDQA+Hx5yIjYBQ18YdklqVml9SDlSQwRRVQkYHBMFYCBoOzITXUoFJBt3DHN/RGYyNG92UgMtAh1ZP2pmNks+HWxSd0wGXXFGdiJ5ahY8BmxFKBIvKUZ3ND5lHDM9TQ==.
All I should be able to do is generate a reply to a key exchange (I will
make the keyid and all that work later when this works). Here is my code
(a little sloppy.. i'll clean it up later):
private static byte[] generateKeyExchangePacket(DSAParameters
dsap, byte[] dhPubKey)
{
byte[] ret = new byte[601];
byte[] publicKey = dsa.GetPublicKey(dsap);
ret[1]=(byte)protocol.OTR_PROTOCOL_VERSION;
ret[2]=10; // Message type (0x0a == 10)
ret[3]=0; // Reply
publicKey.CopyTo(ret,4);
dhPubKey.CopyTo(ret,publicKey.Length+4);
ret[dhPubKey.Length+publicKey.Length+4]=2; //KeyId
SHA1CryptoServiceProvider sha1 = new
SHA1CryptoServiceProvider();
byte[] myEnd = new byte[640];
dsa.Sign(sha1.ComputeHash(ret),dsap).CopyTo(myEnd,600);
ret.CopyTo(myEnd,0);
return myEnd;
}
Ian Goldberg wrote:
>On Sat, Jan 15, 2005 at 12:55:18AM -0500, alex323 wrote:
>
>
>>As you might have heard, I'm making a libary in C# for OTR.
>>
>>
>
>Wow. That's awesome. [Not to mention that it's super-useful to have
>interoperable implementations of a protocol.]
>
>
>
>>I have a few questions however regarding the protocol:
>>
>>* What is the size of the DH key I need to generate? (I don't think it's
>>1536.. I tried it)
>>* I have two editable parameters with my DH class: P and G. Should G be
>>set to 0x02 and P should be set to the key you generated?
>>
>>
>
> - DH y (MPI)
> - The initial DH public encryption key. The DH group is the one
> defined in RFC 3526 with 1536-bit modulus (hex, big-endian):
> FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1
> 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD
> EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245
> E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED
> EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D
> C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F
> 83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D
> 670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF
> and generator 2.
>
>So yes, it's 1536 bits. G = 0x02, and P is the above 1536-bit modulus.
>(We didn't generate it; it's the standard one from RFC 3526.)
>
>
>
>>What about the DSA key length?
>>
>>
>
>1024 bits (the largest the standard allows).
>
>
>
>>* Why doesn't the protocol say that you need to include a NULL (byte 0)
>>as the first character of the key exchange message?
>>
>>
>
>Well, the first field of the Key Exchange Message (after base64-decoding) is:
>
> - Protocol version (SHORT)
> - The version number of this protocol is 0x0001.
>
>So that'd be encoded as \x00\x01. Is that the NUL you're talking about?
>
>
>
>>* Why is there an 'e' in the DSA key? My only options are P, Q, G, Y,
>>and X. Wikipedia told me that X was the private key.
>>
>>
>
>'e' == 'Y'. There was this problem that 'Y' was already used by the DH
>key in the Key Exchange Message. X is indeed the private key [which of
>course never gets sent in the protocol ;-) ]
>
>
>
>>Thanks in advance for your answer(s).
>>
>>
>
>No problem.
>
> - Ian
>_______________________________________________
>OTR-dev mailing list
>OTR-dev at lists.cypherpunks.ca
>http://lists.cypherpunks.ca/mailman/listinfo/otr-dev
>
>
>
More information about the OTR-dev
mailing list