1
unsigned char *prime;
unsigned char *keyPeer;
unsigned char *generator = [self.client readBytesWithLength:2];

unsigned char *keyLengthRaw = [self.client readBytesWithLength:2];
int keyLength = keyLengthRaw[0]*256+keyLengthRaw[1];

prime = [self.client readBytesWithLength:keyLength];
keyPeer = [self.client readBytesWithLength:keyLength];

NSLog(@"key length %d",keyLength);
NSLog(@"---generator: %d", (int) generator[0]*256+generator[1]);
NSLog(@"---prime:");
NSLog([NSString stringWithCString:prime encoding:NSASCIIStringEncoding]);
NSLog(@"---peerkey:");
NSLog([NSString stringWithCString:keyPeer encoding:NSASCIIStringEncoding]);

在此之后我需要做什么来生成 dh 公钥和共享密钥?

4

0 回答 0