inf.length = SSL_OFFSETOF(SSLChannelInfo, reserved); inf.length = PR_MIN(inf.length, len);
inf.length = PR_MIN(sizeof inf, len);
SECStatus SSL_GetChannelInfo(PRFileDesc *fd, SSLChannelInfo *info, PRUintn len){    sslSocket *      ss;    sslSecurityInfo *sec;    SSLChannelInfo   inf;    if (!info) {  /* He doesn't want it?  OK. */    	return SECSuccess;    }    ss = ssl_FindSocket(fd);    if (!ss) {	SSL_DBG(("%d: SSL[%d]: bad socket in SSL_GetChannelInfo",		 SSL_GETPID(), fd));	return SECFailure;    }    memset(&inf, 0, sizeof inf);    inf.length = SSL_OFFSETOF(SSLChannelInfo, reserved);    inf.length = PR_MIN(inf.length, len);    sec = ss->sec;    if (ss->useSecurity && ss->firstHsDone && sec) {	if (ss->version < SSL_LIBRARY_VERSION_3_0) {	    /* SSL2 */	    const BulkCipherInfo * bulk = ssl2CipherInfo + ss->sec->cipherType;	    inf.protocolVersion  = ss->version;	    inf.cipherSuite      = ss->sec->cipherType | 0xff00;	    /* server auth */	    inf.authAlgorithm    = ss->sec->authAlgorithm;	    inf.authKeyBits      = ss->sec->authKeyBits;	    /* key exchange */	    inf.keaType          = ss->sec->keaType;	    inf.keaKeyBits       = ss->sec->keaKeyBits;	    /* symmetric cipher */	    inf.symCipher        = bulk->symCipher;	    inf.symKeyBits       = bulk->symKeyBits;	    inf.symKeySpace      = bulk->symKeySpace;	    inf.effectiveKeyBits = bulk->effectiveKeyBits;	    /* MAC info */	    inf.macAlgorithm     = ssl_mac_md5;	    inf.macBits          = MD5_LENGTH * BPB;	    /* misc */	    inf.isFIPS           = 0;	} else if (ss->ssl3 && ss->ssl3->crSpec && 	           ss->ssl3->crSpec->cipher_def) {	    /* SSL3 and TLS */	    ssl3CipherSpec *          crSpec     = ss->ssl3->crSpec;	    const ssl3BulkCipherDef * cipher_def = crSpec->cipher_def;	    /* XXX NBB These should come from crSpec */	    inf.protocolVersion      = ss->version;	    inf.cipherSuite          = ss->ssl3->hs.cipher_suite;	    /* server auth */	    inf.authAlgorithm        = ss->sec->authAlgorithm;	    inf.authKeyBits          = ss->sec->authKeyBits;	    /* key exchange */	    inf.keaType              = ss->sec->keaType;	    inf.keaKeyBits           = ss->sec->keaKeyBits;	    /* symmetric cipher */	    inf.symCipher            = cipher_def->calg;	    switch (inf.symCipher) {	    case ssl_calg_des:		inf.symKeyBits       = cipher_def->key_size        * 8 ;		inf.symKeySpace      = \		inf.effectiveKeyBits = cipher_def->secret_key_size * 7 ;		break;	    case ssl_calg_3des:		inf.symKeyBits       = cipher_def->key_size        * 8 ;		inf.symKeySpace      = cipher_def->secret_key_size * 7 ;		inf.effectiveKeyBits = (inf.symKeySpace / 3 ) * 2;		break;	    default:		inf.symKeyBits       = cipher_def->key_size * BPB ;		inf.symKeySpace      = \		inf.effectiveKeyBits = cipher_def->secret_key_size * BPB ;		break;            }	    /* MAC info */	    inf.macAlgorithm         = crSpec->mac_def->mac;	    inf.macBits              = crSpec->mac_def->mac_size * BPB;	    /* misc */	    inf.isFIPS =  (inf.symCipher == ssl_calg_des ||	                   inf.symCipher == ssl_calg_3des ||	                   inf.symCipher == ssl_calg_aes)		       && (inf.macAlgorithm == ssl_mac_sha ||		           inf.macAlgorithm == ssl_hmac_sha)		       && (inf.protocolVersion > SSL_LIBRARY_VERSION_3_0 ||		           inf.cipherSuite >= 0xfef0);	}    }    inf.authAlgorithmName = authName[  inf.authAlgorithm];    inf.keaTypeName       = keaName[   inf.keaType      ];    inf.symCipherName     = cipherName[inf.symCipher    ];    inf.macAlgorithmName  = macName[   inf.macAlgorithm ];    memcpy(info, &inf, inf.length);    return SECSuccess;}