Computes an appropriate LMv2 response based on the supplied arguments
        The algorithm is based on jCIFS. The response is 24 bytes, with the 16 bytes of hash
        concatenated with the 8 byte client client_challenge
343180
def get_lmv2_response(domain, username, password, server_challenge, client_challenge):
        
        ntlmv2_hash = PasswordAuthentication.ntowfv2(domain, username, password.encode('utf-16le'))
        hmac_context = hmac.HMAC(ntlmv2_hash, hashes.MD5(), backend=default_backend())
        hmac_context.update(server_challenge)
        hmac_context.update(client_challenge)
        lmv2_hash = hmac_context.finalize()

        # The LMv2 master user session key is a HMAC MD5 of the NTLMv2 and LMv2 hash
        session_key = hmac.HMAC(ntlmv2_hash, hashes.MD5(), backend=default_backend())
        session_key.update(lmv2_hash)

        return lmv2_hash + client_challenge, session_key.finalize()
191891
private Response<Bitmap> doParse(NetworkResponse response) {
        byte[] data = response.data;
        BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
        Bitmap bitmap = null;
        if (mMaxWidth == 0 && mMaxHeight == 0) {
            decodeOptions.inPreferredConfig = mDecodeConfig;
            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);
        } else {
            // If we have to resize this image, first get the natural bounds.
            decodeOptions.inJustDecodeBounds = true;
            BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);
            int actualWidth = decodeOptions.outWidth;
            int actualHeight = decodeOptions.outHeight;

            // Then compute the dimensions we would ideally like to decode to.
            int desiredWidth = getResizedDimension(mMaxWidth, mMaxHeight,
                    actualWidth, actualHeight, mScaleType);
            int desiredHeight = getResizedDimension(mMaxHeight, mMaxWidth,
                    actualHeight, actualWidth, mScaleType);

            // Decode to the nearest power of two scaling factor.
            decodeOptions.inJustDecodeBounds = false;

             decodeOptions.inPreferQualityOverSpeed = PREFER_QUALITY_OVER_SPEED;
            decodeOptions.inSampleSize =
                findBestSampleSize(actualWidth, actualHeight, desiredWidth, desiredHeight);
            Bitmap tempBitmap =
                BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);

            // If necessary, scale down to the maximal acceptable size.
            if (tempBitmap != null && (tempBitmap.getWidth() > desiredWidth ||
                    tempBitmap.getHeight() > desiredHeight)) {
                bitmap = Bitmap.createScaledBitmap(tempBitmap,
                        desiredWidth, desiredHeight, true);
            } else {
                bitmap = tempBitmap;
            }
        }

        if (bitmap == null) {
            return Response.error(new ParseError(response));
        } else {
            return Response.success(bitmap, HttpHeaderParser.parseCacheHeaders(response));
        }
    }
1107019
def signature_unsafe(m, sk, pk, hash_func=H):
    
    h = hash_func(sk)
    a = 2 ** (b - 2) + sum(2 ** i * bit(h, i) for i in range(3, b - 2))
    r = Hint(bytearray([h[j] for j in range(b // 8, b // 4)]) + m)
    R = scalarmult_B(r)
    S = (r + Hint(encodepoint(R) + pk + m) * a) % l
    return bytes(encodepoint(R) + encodeint(S))
848651
function _challengeResponse($lm = false)
    {
        if ($lm) {
            $hash = $this->lmPasswordHash();
        } else {
            $hash = $this->ntPasswordHash();
        }

        while (strlen($hash) < 21) {
            $hash .= "\0";
        }

        $td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        $key = $this->_desAddParity(substr($hash, 0, 7));
        mcrypt_generic_init($td, $key, $iv);
        $resp1 = mcrypt_generic($td, $this->challenge);
        mcrypt_generic_deinit($td);

        $key = $this->_desAddParity(substr($hash, 7, 7));
        mcrypt_generic_init($td, $key, $iv);
        $resp2 = mcrypt_generic($td, $this->challenge);
        mcrypt_generic_deinit($td);

        $key = $this->_desAddParity(substr($hash, 14, 7));
        mcrypt_generic_init($td, $key, $iv);
        $resp3 = mcrypt_generic($td, $this->challenge);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);

        return $resp1 . $resp2 . $resp3;
    }
1339384
def req2frame(req, N: int=0):
    
    if req is None:
        frame = np.arange(N, dtype=np.int64)
    elif isinstance(req, int):  # the user is specifying a step size
        frame = np.arange(0, N, req, dtype=np.int64)
    elif len(req) == 1:
        frame = np.arange(0, N, req[0], dtype=np.int64)
    elif len(req) == 2:
        frame = np.arange(req[0], req[1], dtype=np.int64)
    elif len(req) == 3:
        # this is -1 because user is specifying one-based index
        frame = np.arange(req[0], req[1], req[2],
                          dtype=np.int64) - 1  # keep -1 !
    else:  # just return all frames
        frame = np.arange(N, dtype=np.int64)

    return frame
1021520
def rfc6979_ecdsa_nonce(hash, privkey)
      raise ArgumentError, "Hash must be 32 bytes long" if hash.bytesize != 32
      raise ArgumentError, "Private key must be 32 bytes long" if privkey.bytesize != 32

      autorelease do |pool|
        order = self.group_order

        # Step 3.2.a. hash = H(message). Already performed by the caller.

        # Step 3.2.b. V = 0x01 0x01 0x01 ... 0x01 (32 bytes equal 0x01)
        v = "\x01".b*32

        # Step 3.2.c. K = 0x00 0x00 0x00 ... 0x00 (32 bytes equal 0x00)
        k = "\x00".b*32

        # Step 3.2.d. K = HMAC-SHA256(key: K, data: V || 0x00 || int2octets(privkey) || bits2octets(hash))
        h1 = pool.new_bn(hash)
        BN_div(nil, h1, h1, order, pool.bn_ctx) # h1 = h1 % order
        h1data = data_from_bn(h1, min_length: 32)
        k = BTC.hmac_sha256(key: k, data: v + "\x00".b + privkey + h1data)

        # Step 3.2.e. V = HMAC-SHA256(key: K, data: V)
        v = BTC.hmac_sha256(key: k, data: v)

        # Step 3.2.f. K = HMAC-SHA256(key: K, data: V || 0x01 || int2octets(privkey) || bits2octets(hash))
        k = BTC.hmac_sha256(key: k, data: v + "\x01".b + privkey + h1data)

        # Step 3.2.g. V = HMAC-SHA256(key: K, data: V)
        v = BTC.hmac_sha256(key: k, data: v)

        # Step 3.2.h.
        zero32 = "\x00".b*32
        10000.times do
          t = BTC.hmac_sha256(key: k, data: v)
          tn = pool.new_bn(t)
          if BN_cmp(tn, order) < 0
            nonce = data_from_bn(tn, min_length: 32)
            if nonce != zero32
              return nonce
            end
          end
          # Note: the probability of not succeeding at the first try is about 2^-127.
          k = BTC.hmac_sha256(key: k, data: v + zero32)
          v = BTC.hmac_sha256(key: k, data: v)
        end
        # we generated 10000 numbers, none of them is good -> fail.
        raise "Cannot find any good ECDSA nonce after 10000 iterations of RFC6979."
      end
    end
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;
	}
510638
def compute_hkdf(ikm, salt):
    
    prk = hmac.new(salt, ikm, hashlib.sha256).digest()
    info_bits_update = info_bits + bytearray(chr(1), 'utf-8')
    hmac_hash = hmac.new(prk, info_bits_update, hashlib.sha256).digest()
    return hmac_hash[:16]
876467
def demand
      s1 = @index2.size / 2
      j0 = INT.new( 0 ).major( @index0 + s1 + 1 - @index1.size )
      if @initial
        retval = @initial.simplify
      else
        j = j0.get
        i = @index0.get + s1.get - j
        retval = @value.subst( @index1 => INT.new( i ),
                               @index2 => INT.new( j ) ).simplify
        j0 = ( j0 + 1 ).simplify
      end
      j0.upto( ( @index2.size - 1 ).minor( @index0 + s1 ) ) do |j|
        i = @index0.get + s1.get - j
        sub = @value.subst @index1 => INT.new( i ), @index2 => INT.new( j )
        retval.assign @block.subst( @var1 => retval, @var2 => sub )
      end
      retval
    end
33176
def get_ntlmv1_response(password, challenge):
        
        ntlm_hash = PasswordAuthentication.ntowfv1(password.encode('utf-16le'))
        response  = PasswordAuthentication._encrypt_des_block(ntlm_hash[:7], challenge)
        response += PasswordAuthentication._encrypt_des_block(ntlm_hash[7:14], challenge)
        response += PasswordAuthentication._encrypt_des_block(ntlm_hash[14:], challenge)

        # The NTLMv1 session key is simply the MD4 hash of the ntlm hash
        session_hash = hashlib.new('md4')
        session_hash.update(ntlm_hash)
        return response, session_hash.digest()
236969
def build_response_packet
      rpacket = Packet::Source.new
      total_size = 0
      request_id = 0
      type = 0
      response = ""
      message = ""
    

      loop do
        break unless IO.select([@socket], nil, nil, 10)

        #
        # TODO: clean this up - read everything and then unpack.
        #

        tmp = @socket.recv(14)
        if tmp.nil?
          return nil
        end
        size, request_id, type, message = tmp.unpack("VVVa*")
        total_size += size
      
        # special case for authentication
        break if message.sub! /\x00\x00$/, ""

        response << message

        # the 'size - 10' here accounts for the fact that we've snarfed 14 bytes,
        # the size (which is 4 bytes) is not counted, yet represents the rest
        # of the packet (which we have already taken 10 bytes from)

        tmp = @socket.recv(size - 10)
        response << tmp
        response.sub! /\x00\x00$/, ""
      end
    
      rpacket.packet_size = total_size
      rpacket.request_id = request_id
      rpacket.command_type = type
    
      # strip nulls (this is actually the end of string1 and string2)
      rpacket.string1 = response.sub /\x00\x00$/, ""
      return rpacket
    end
747296
def crypto_shorthash_siphash24(data, key):
    
    if len(key) != KEYBYTES:
        raise exc.ValueError(
            "Key length must be exactly {0} bytes".format(KEYBYTES))
    digest = ffi.new("unsigned char[]", BYTES)
    rc = lib.crypto_shorthash_siphash24(digest, data, len(data), key)

    ensure(rc == 0, raising=exc.RuntimeError)
    return ffi.buffer(digest, BYTES)[:]
638128
def get_t_response(self, forceSignal=None):
        
        if forceSignal is not None:
            response = six.b('T' + conversion.byte_to_hex2(forceSignal))
        else:
            response = six.b('T' + conversion.byte_to_hex2(self.get_signal_value()))

        # Append fp(r7), sp(r13), lr(r14), pc(r15)
        response += self.get_reg_index_value_pairs([7, 13, 14, 15])

        return response
520323
def img2img_transformer2d_n24():
  """"""
  hparams = img2img_transformer2d_base()
  hparams.batch_size = 1
  hparams.hidden_size = 1024
  hparams.filter_size = 2048
  hparams.layer_prepostprocess_dropout = 0.2
  hparams.num_decoder_layers = 8
  hparams.query_shape = (8, 16)
  hparams.memory_flange = (8, 32)
  return hparams
1141795
def Recv(self):
    
    size = struct.unpack(_STRUCT_FMT, self._ReadN(_STRUCT_LEN))[0]
    if size > MAX_SIZE:
      raise ProtocolError("Expected size to be at most %d, got %d" % (MAX_SIZE,
                                                                      size))
    with self._read_lock:
      buf = self._ReadN(size)
      self._ReadMagic()

    res = common_pb2.Message()
    res.ParseFromString(buf)

    return res, len(buf)
440564
int guessPayloadLength() {
    int length = 0;
    byte[] payload = (byte[])getPayload().getField(JmsBytesBodyAccess.BODY_DATA_VALUE);
    if (payload != null) {
      length = payload.length + 24;
    }
    return length;
  }
604719
def hash(self, *args, **kwargs):
        
        joiner = kwargs.get('joiner', '').encode('utf-8')
        as_bytes = kwargs.get('as_bytes', False)

        def conv(arg):
            if isinstance(arg, integer_types):
                arg = int_to_bytes(arg)

            if PY3:
                if isinstance(arg, str):
                    arg = arg.encode('utf-8')
                return arg

            return str(arg)

        digest = joiner.join(map(conv, args))

        hash_obj = self._hash_func(digest)

        if as_bytes:
            return hash_obj.digest()

        return int_from_hex(hash_obj.hexdigest())