Returns the effective user session key.

@param challenge The server challenge.
@return A <code>byte[]</code> containing the effective user session key,
used in SMB MAC signing and NTLMSSP signing and sealing.
186234
public byte[] getUserSessionKey(byte[] challenge) {
        if (hashesExternal) return null;
        byte[] key = new byte[16];
        try {
            getUserSessionKey(challenge, key, 0); 
        } catch (Exception ex) {
            if( log.level > 0 )
                ex.printStackTrace( log );
        }
        return key; 
    }
313472
public boolean[] getKeyUsageMappedBits() {
        KeyUsageExtension keyUsage = new KeyUsageExtension();
        Boolean val = Boolean.TRUE;

        try {
            if (isSet(getPosition(SSL_CLIENT)) ||
                isSet(getPosition(S_MIME)) ||
                isSet(getPosition(OBJECT_SIGNING)))
                keyUsage.set(KeyUsageExtension.DIGITAL_SIGNATURE, val);

            if (isSet(getPosition(SSL_SERVER)))
                keyUsage.set(KeyUsageExtension.KEY_ENCIPHERMENT, val);

            if (isSet(getPosition(SSL_CA)) ||
                isSet(getPosition(S_MIME_CA)) ||
                isSet(getPosition(OBJECT_SIGNING_CA)))
                keyUsage.set(KeyUsageExtension.KEY_CERTSIGN, val);
        } catch (IOException e) { }
        return keyUsage.getBits();
    }
677827
public byte[] getAnsiHash( byte[] challenge ) {
        if( hashesExternal ) {
            return ansiHash;
        }
        switch (LM_COMPATIBILITY) {
        case 0:
        case 1:
            return getPreNTLMResponse( password, challenge );
        case 2:
            return getNTLMResponse( password, challenge );
        case 3:
        case 4:
        case 5:
            if( clientChallenge == null ) {
                clientChallenge = new byte[8];
                RANDOM.nextBytes( clientChallenge );
            }
            return getLMv2Response(domain, username, password, challenge,
                    clientChallenge);
        default:
            return getPreNTLMResponse( password, challenge );
        }
    }
694378
public byte[] getEncoded() throws SshException {
		ByteArrayWriter baw = new ByteArrayWriter();
		try {
			baw.writeString(getAlgorithm());
			baw.writeBinaryString(cert.getEncoded());
			return baw.toByteArray();
		} catch (Throwable ex) {
			throw new SshException("Failed to encoded key data",
					SshException.INTERNAL_ERROR, ex);
		} finally {
			try {
				baw.close();
			} catch (IOException e) {
			}
		}
	}
1321347
public function isValidResponse($username, $hash, $challenge)
	{
		if(self::NTLM_BLOB_HEADER != substr($this->clientBlob, 0, 8))
		{
			return false;
		}
	
		// Timstamp, seconds since january 1, 1601, used in replay-attack prevention.
		// 	$str = (float)vsprintf('%u%04u%04u%04u', array_reverse(unpack('vt1/vt2/vt3/vt4', substr($this->clientBlob, 8, 8))));
		// 	$seconds = floor($str / 1000000);
	
		// Client nonce, useful in replay-attack prevention.
		// 	$cnonce = substr($this->clientBlob, 16, 8);
	
		if(!SecurityUtil::timingSafeEquals($username, $this->username))
		{
			return false;
		}
		
		if(!SecurityUtil::timingSafeEquals($this->provider->getDomain(), $this->domain))
		{
			return false;
		}
		
		$ntlmhash = $this->computeHmacMd5($hash, $this->encodeUtf16(strtoupper($this->username) . $this->domain));
		$hash = (string)$this->computeHmacMd5($ntlmhash, $challenge . $this->clientBlob);
		
		if(!SecurityUtil::timingSafeEquals($hash, $this->clientHash))
		{
			return false;
		}
		
		return true;
	}
1273742
def get_sid(self):
        """"""
        base_url = u'%s/login_sid.lua' % self.__fritz_url
        get_challenge = None
        try:
            get_challenge = urllib2.urlopen(base_url).read().decode('ascii')
        except urllib2.HTTPError as exception:
            print('HTTPError = ' + str(exception.code))
        except urllib2.URLError as  exception:
            print('URLError = ' + str(exception.reason))
        except Exception as exception:
            print('generic exception: ' + str(exception))
            raise


        challenge = get_challenge.split(
            '<Challenge>')[1].split('</Challenge>')[0]
        challenge_b = (
            challenge + '-' + self.__password).encode().decode('iso-8859-1').encode('utf-16le')

        md5hash = hashlib.md5()
        md5hash.update(challenge_b)

        response_b = challenge + '-' + md5hash.hexdigest().lower()
        get_sid = urllib2.urlopen('%s?%sresponse=%s' % (base_url, self.__username_query, response_b)).read().decode('utf-8')
        self.sid = get_sid.split('<SID>')[1].split('</SID>')[0]
1324190
public static java.security.KeyPair generateLongTermRevocationKey() {
        try {
            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
            SecureRandom random = new SecureRandom();
            AlgorithmParameterSpec params = new ECGenParameterSpec("secp384r1");
            keyGen.initialize(params, random);

            return keyGen.generateKeyPair();
        } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
            throw new RuntimeException("Error during the LTRevocation key. Invalid algorithm");
        }
    }
1359130
def sign_ssh_challenge(self, blob, identity):
        """"""
        msg = _parse_ssh_blob(blob)
        log.debug('%s: user %r via %r (%r)',
                  msg['conn'], msg['user'], msg['auth'], msg['key_type'])
        log.debug('nonce: %r', msg['nonce'])
        fp = msg['public_key']['fingerprint']
        log.debug('fingerprint: %s', fp)
        log.debug('hidden challenge size: %d bytes', len(blob))

        log.info('please confirm user "%s" login to "%s" using %s...',
                 msg['user'].decode('ascii'), identity.to_string(),
                 self.device)

        with self.device:
            return self.device.sign(blob=blob, identity=identity)
1332819
protected byte[] getBinaryRequestPayload(SignableRequest<?> request) {
        if (SdkHttpUtils.usePayloadForQueryParameters(request)) {
            String encodedParameters = SdkHttpUtils.encodeParameters(request);
            if (encodedParameters == null)
                return new byte[0];

            return encodedParameters.getBytes(UTF8);
        }

        return getBinaryRequestPayloadWithoutQueryParams(request);
    }
923301
public static byte[] generateSecretKey() {
    final byte[] k = new byte[KEY_LEN];
    final SecureRandom random = new SecureRandom();
    random.nextBytes(k);
    return k;
  }
495435
function(pk, challenge, signature) {
    var pem = "-----BEGIN RSA PUBLIC KEY-----\n" 
        + pk.replace(/(.{64})/g, "$1\n")
        + "\n-----END RSA PUBLIC KEY-----";

    var rsa = crypto.createVerify("RSA-SHA256");
    rsa.update(new Buffer(challenge, "base64"));
    if(rsa.verify(pem, signature, "base64"))
    {
        return { result : true };
    }
    else {
        return { result : false };
    }
}
1074721
@Override
  public String cipherSuite()
  {
    if (! (_s instanceof SSLSocket)) {
      return super.cipherSuite();
    }

    SSLSocket sslSocket = (SSLSocket) _s;
    
    SSLSession sslSession = sslSocket.getSession();
    
    if (sslSession != null) {
      return sslSession.getCipherSuite();
    }
    else {
      return null;
    }
  }
122001
def hmac_signature(string, shared_secret, challenge_hmac):
    '''
    
    '''
    msg = salt.utils.stringutils.to_bytes(string)
    key = salt.utils.stringutils.to_bytes(shared_secret)
    challenge = salt.utils.stringutils.to_bytes(challenge_hmac)
    hmac_hash = hmac.new(key, msg, hashlib.sha256)
    valid_hmac = base64.b64encode(hmac_hash.digest())
    return valid_hmac == challenge
974590
public RespondToAuthChallengeResult withChallengeParameters(java.util.Map<String, String> challengeParameters) {
        setChallengeParameters(challengeParameters);
        return this;
    }
505729
public synchronized String getSignature(long nonce) {
    return HexEncoder.encode(sha256HMAC.doFinal(buildSignatureData(nonce)))
        .toLowerCase(Locale.ROOT);
  }
157909
def _get_auth_challenge(self, exc):
        
        response = HttpResponse(content=exc.content, status=exc.get_code_num())
        response['WWW-Authenticate'] = 'Basic realm="%s"' % REALM
        return response
1177107
protected function authNtlmMessageType3( $challenge, $user, $password, $workstation, $domain )
    {
        $domain = chunk_split( $domain, 1, "\x00" );
        $user = chunk_split( $user, 1, "\x00" );
        $workstation = chunk_split( $workstation, 1, "\x00" );
        $lm = '';
        $ntlm = $this->authNtlmResponse( $challenge, $password );
        $session = '';

        $domainOffset = 64;
        $userOffset = $domainOffset + strlen( $domain );
        $workstationOffset = $userOffset + strlen( $user );
        $lmOffset = $workstationOffset + strlen( $workstation );
        $ntlmOffset = $lmOffset + strlen( $lm );
        $sessionOffset = $ntlmOffset + strlen( $ntlm );

        $parts = array(
                        "NTLMSSP\x00",
                        "\x03\x00\x00\x00",
                        $this->authNtlmSecurityBuffer( $lm, $lmOffset ),
                        $this->authNtlmSecurityBuffer( $ntlm, $ntlmOffset ),
                        $this->authNtlmSecurityBuffer( $domain, $domainOffset ),
                        $this->authNtlmSecurityBuffer( $user, $userOffset ),
                        $this->authNtlmSecurityBuffer( $workstation, $workstationOffset ),
                        $this->authNtlmSecurityBuffer( $session, $sessionOffset ),
                        "\x01\x02\x00\x00",
                        $domain,
                        $user,
                        $workstation,
                        $lm,
                        $ntlm
                      );

        return implode( '', $parts );
    }