XMPPDiscoEntity: Caps hash must be Base64 encoded SHA1

This commit is contained in:
Florian Zeitz 2013-06-12 14:53:05 +02:00
parent bd0440b3ee
commit bfdfabcf40

View file

@ -90,10 +90,12 @@
- (OFString*)capsHash - (OFString*)capsHash
{ {
OFMutableString *caps = [OFMutableString string];
OFEnumerator *enumerator; OFEnumerator *enumerator;
XMPPDiscoIdentity *identity; XMPPDiscoIdentity *identity;
OFString *feature; OFString *feature;
OFMutableString *caps = [OFMutableString string];
OFSHA1Hash *hash = [OFSHA1Hash hash];
OFDataArray *digest = [OFDataArray dataArray];
enumerator = [_identities objectEnumerator]; enumerator = [_identities objectEnumerator];
while ((identity = [enumerator nextObject]) != nil) while ((identity = [enumerator nextObject]) != nil)
@ -104,7 +106,13 @@
while ((feature = [enumerator nextObject]) != nil) while ((feature = [enumerator nextObject]) != nil)
[caps appendFormat: @"%@<", feature]; [caps appendFormat: @"%@<", feature];
return [caps SHA1Hash]; [hash updateWithBuffer: [caps UTF8String]
length: [caps UTF8StringLength]];
[digest addItems: [hash digest]
count: [OFSHA1Hash digestSize]];
return [digest stringByBase64Encoding];
} }
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection*)connection