idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
44,600 | function _i2osp ( $ x , $ xLen ) { $ x = $ x -> toBytes ( ) ; if ( strlen ( $ x ) > $ xLen ) { user_error ( 'Integer too large' ) ; return false ; } return str_pad ( $ x , $ xLen , chr ( 0 ) , STR_PAD_LEFT ) ; } | Integer - to - Octet - String primitive |
44,601 | function _blind ( $ x , $ r , $ i ) { $ x = $ x -> multiply ( $ r -> modPow ( $ this -> publicExponent , $ this -> primes [ $ i ] ) ) ; $ x = $ x -> modPow ( $ this -> exponents [ $ i ] , $ this -> primes [ $ i ] ) ; $ r = $ r -> modInverse ( $ this -> primes [ $ i ] ) ; $ x = $ x -> multiply ( $ r ) ; list ( , $ x ) = $ x -> divide ( $ this -> primes [ $ i ] ) ; return $ x ; } | Performs RSA Blinding |
44,602 | function _equals ( $ x , $ y ) { if ( strlen ( $ x ) != strlen ( $ y ) ) { return false ; } $ result = 0 ; for ( $ i = 0 ; $ i < strlen ( $ x ) ; $ i ++ ) { $ result |= ord ( $ x [ $ i ] ) ^ ord ( $ y [ $ i ] ) ; } return $ result == 0 ; } | Performs blinded RSA equality testing |
44,603 | function _rsaes_oaep_decrypt ( $ c , $ l = '' ) { if ( strlen ( $ c ) != $ this -> k || $ this -> k < 2 * $ this -> hLen + 2 ) { user_error ( 'Decryption error' ) ; return false ; } $ c = $ this -> _os2ip ( $ c ) ; $ m = $ this -> _rsadp ( $ c ) ; if ( $ m === false ) { user_error ( 'Decryption error' ) ; return false ; } $ em = $ this -> _i2osp ( $ m , $ this -> k ) ; $ lHash = $ this -> hash -> hash ( $ l ) ; $ y = ord ( $ em [ 0 ] ) ; $ maskedSeed = substr ( $ em , 1 , $ this -> hLen ) ; $ maskedDB = substr ( $ em , $ this -> hLen + 1 ) ; $ seedMask = $ this -> _mgf1 ( $ maskedDB , $ this -> hLen ) ; $ seed = $ maskedSeed ^ $ seedMask ; $ dbMask = $ this -> _mgf1 ( $ seed , $ this -> k - $ this -> hLen - 1 ) ; $ db = $ maskedDB ^ $ dbMask ; $ lHash2 = substr ( $ db , 0 , $ this -> hLen ) ; $ m = substr ( $ db , $ this -> hLen ) ; if ( ! $ this -> _equals ( $ lHash , $ lHash2 ) ) { user_error ( 'Decryption error' ) ; return false ; } $ m = ltrim ( $ m , chr ( 0 ) ) ; if ( ord ( $ m [ 0 ] ) != 1 ) { user_error ( 'Decryption error' ) ; return false ; } return substr ( $ m , 1 ) ; } | RSAES - OAEP - DECRYPT |
44,604 | function _emsa_pss_encode ( $ m , $ emBits ) { $ emLen = ( $ emBits + 1 ) >> 3 ; $ sLen = $ this -> sLen !== null ? $ this -> sLen : $ this -> hLen ; $ mHash = $ this -> hash -> hash ( $ m ) ; if ( $ emLen < $ this -> hLen + $ sLen + 2 ) { user_error ( 'Encoding error' ) ; return false ; } $ salt = Random :: string ( $ sLen ) ; $ m2 = "\0\0\0\0\0\0\0\0" . $ mHash . $ salt ; $ h = $ this -> hash -> hash ( $ m2 ) ; $ ps = str_repeat ( chr ( 0 ) , $ emLen - $ sLen - $ this -> hLen - 2 ) ; $ db = $ ps . chr ( 1 ) . $ salt ; $ dbMask = $ this -> _mgf1 ( $ h , $ emLen - $ this -> hLen - 1 ) ; $ maskedDB = $ db ^ $ dbMask ; $ maskedDB [ 0 ] = ~ chr ( 0xFF << ( $ emBits & 7 ) ) & $ maskedDB [ 0 ] ; $ em = $ maskedDB . $ h . chr ( 0xBC ) ; return $ em ; } | EMSA - PSS - ENCODE |
44,605 | function _rsassa_pss_verify ( $ m , $ s ) { if ( strlen ( $ s ) != $ this -> k ) { user_error ( 'Invalid signature' ) ; return false ; } $ modBits = 8 * $ this -> k ; $ s2 = $ this -> _os2ip ( $ s ) ; $ m2 = $ this -> _rsavp1 ( $ s2 ) ; if ( $ m2 === false ) { user_error ( 'Invalid signature' ) ; return false ; } $ em = $ this -> _i2osp ( $ m2 , $ modBits >> 3 ) ; if ( $ em === false ) { user_error ( 'Invalid signature' ) ; return false ; } return $ this -> _emsa_pss_verify ( $ m , $ em , $ modBits - 1 ) ; } | RSASSA - PSS - VERIFY |
44,606 | function _rsassa_pkcs1_v1_5_sign ( $ m ) { $ em = $ this -> _emsa_pkcs1_v1_5_encode ( $ m , $ this -> k ) ; if ( $ em === false ) { user_error ( 'RSA modulus too short' ) ; return false ; } $ m = $ this -> _os2ip ( $ em ) ; $ s = $ this -> _rsasp1 ( $ m ) ; $ s = $ this -> _i2osp ( $ s , $ this -> k ) ; return $ s ; } | RSASSA - PKCS1 - V1_5 - SIGN |
44,607 | function verify ( $ message , $ signature ) { if ( empty ( $ this -> modulus ) || empty ( $ this -> exponent ) ) { return false ; } switch ( $ this -> signatureMode ) { case self :: SIGNATURE_PKCS1 : return $ this -> _rsassa_pkcs1_v1_5_verify ( $ message , $ signature ) ; default : return $ this -> _rsassa_pss_verify ( $ message , $ signature ) ; } } | Verifies a signature |
44,608 | function _extractBER ( $ str ) { $ temp = preg_replace ( '#.*?^-+[^-]+-+[\r\n ]*$#ms' , '' , $ str , 1 ) ; $ temp = preg_replace ( '#-+[^-]+-+#' , '' , $ temp ) ; $ temp = str_replace ( array ( "\r" , "\n" , ' ' ) , '' , $ temp ) ; $ temp = preg_match ( '#^[a-zA-Z\d/+]*={0,2}$#' , $ temp ) ? base64_decode ( $ temp ) : false ; return $ temp != false ? $ temp : $ str ; } | Extract raw BER from Base64 encoding |
44,609 | public function setPaths ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> paths = $ arr ; return $ this ; } | The set of field mask paths . |
44,610 | public function setEnumvalue ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ EnumValue :: class ) ; $ this -> enumvalue = $ arr ; return $ this ; } | Enum value definitions . |
44,611 | function _mdsrem ( $ A , $ B ) { for ( $ i = 0 ; $ i < 8 ; ++ $ i ) { $ t = 0xff & ( $ B >> 24 ) ; $ B = ( $ B << 8 ) | ( 0xff & ( $ A >> 24 ) ) ; $ A <<= 8 ; $ u = $ t << 1 ; if ( $ t & 0x80 ) { $ u ^= 0x14d ; } $ B ^= $ t ^ ( $ u << 16 ) ; $ u ^= 0x7fffffff & ( $ t >> 1 ) ; if ( $ t & 0x01 ) { $ u ^= 0xa6 ; } $ B ^= ( $ u << 24 ) | ( $ u << 8 ) ; } return array ( 0xff & $ B >> 24 , 0xff & $ B >> 16 , 0xff & $ B >> 8 , 0xff & $ B ) ; } | _mdsrem function using by the twofish cipher algorithm |
44,612 | public function getPostalAddress ( ) { $ postalAddress = $ this -> getProfileAttribute ( self :: ATTR_POSTAL_ADDRESS ) ; if ( null === $ postalAddress ) { $ postalAddress = $ this -> getFormattedAddress ( ) ; } return $ postalAddress ; } | Return postal_address or structured_postal_address . formatted_address . |
44,613 | private function getAgeVerificationByAttribute ( $ ageAttr ) { $ ageVerifications = $ this -> getAgeVerifications ( ) ; return isset ( $ ageVerifications [ $ ageAttr ] ) ? $ ageVerifications [ $ ageAttr ] : null ; } | Return AgeVerification . |
44,614 | private static function convertMultiValue ( $ value ) { $ protoMultiValue = new \ Attrpubapi \ MultiValue ( ) ; $ protoMultiValue -> mergeFromString ( $ value ) ; $ items = [ ] ; foreach ( $ protoMultiValue -> getValues ( ) as $ protoValue ) { $ items [ ] = self :: convertValueBasedOnContentType ( $ protoValue -> getData ( ) , $ protoValue -> getContentType ( ) ) ; } return new MultiValue ( $ items ) ; } | Convert attribute value to MultiValue . |
44,615 | private static function imageTypeToExtension ( $ type ) { $ type = ( int ) $ type ; switch ( $ type ) { case 2 : $ format = 'JPEG' ; break ; case 4 : $ format = 'PNG' ; break ; default : $ format = 'UNSUPPORTED' ; } return $ format ; } | Convert Protobuf Image type to an image extension . |
44,616 | public static function convertToYotiAttribute ( ProtobufAttribute $ protobufAttribute ) { $ yotiAttribute = null ; if ( $ protobufAttribute -> getName ( ) == ApplicationProfile :: ATTR_APPLICATION_LOGO && empty ( $ protobufAttribute -> getValue ( ) ) ) { return $ yotiAttribute ; } try { $ yotiAnchorsMap = AnchorListConverter :: convert ( $ protobufAttribute -> getAnchors ( ) ) ; $ attrValue = AttributeConverter :: convertValueBasedOnContentType ( $ protobufAttribute -> getValue ( ) , $ protobufAttribute -> getContentType ( ) ) ; $ attrName = $ protobufAttribute -> getName ( ) ; $ attrValue = AttributeConverter :: convertValueBasedOnAttributeName ( $ attrValue , $ attrName ) ; $ yotiAttribute = new Attribute ( $ attrName , $ attrValue , $ yotiAnchorsMap ) ; } catch ( AttributeException $ e ) { error_log ( "{$e->getMessage()} (Attribute: {$protobufAttribute->getName()})" , 0 ) ; } catch ( \ Exception $ e ) { error_log ( $ e -> getMessage ( ) , 0 ) ; } return $ yotiAttribute ; } | Return a Yoti Attribute . |
44,617 | public function toDateTime ( ) { $ time = sprintf ( '%s.%06d' , $ this -> seconds , $ this -> nanos / 1000 ) ; return \ DateTime :: createFromFormat ( 'U.u' , $ time ) ; } | Converts Timestamp to PHP DateTime . |
44,618 | public function unpack ( ) { $ url_prifix_len = strlen ( GPBUtil :: TYPE_URL_PREFIX ) ; if ( substr ( $ this -> type_url , 0 , $ url_prifix_len ) != GPBUtil :: TYPE_URL_PREFIX ) { throw new \ Exception ( "Type url needs to be type.googleapis.com/fully-qulified" ) ; } $ fully_qualifed_name = substr ( $ this -> type_url , $ url_prifix_len ) ; $ pool = \ Google \ Protobuf \ Internal \ DescriptorPool :: getGeneratedPool ( ) ; $ desc = $ pool -> getDescriptorByProtoName ( "." . $ fully_qualifed_name ) ; if ( is_null ( $ desc ) ) { throw new \ Exception ( "Class " . $ fully_qualifed_name . " hasn't been added to descriptor pool" ) ; } $ klass = $ desc -> getClass ( ) ; $ msg = new $ klass ( ) ; $ msg -> mergeFromString ( $ this -> value ) ; return $ msg ; } | This method will try to resolve the type_url in Any message to get the targeted message type . If failed an error will be thrown . Otherwise the method will create a message of the targeted type and fill it with the decoded value in Any . |
44,619 | public function is ( $ klass ) { $ pool = \ Google \ Protobuf \ Internal \ DescriptorPool :: getGeneratedPool ( ) ; $ desc = $ pool -> getDescriptorByClassName ( $ klass ) ; $ fully_qualifed_name = $ desc -> getFullName ( ) ; $ type_url = GPBUtil :: TYPE_URL_PREFIX . substr ( $ fully_qualifed_name , 1 , strlen ( $ fully_qualifed_name ) ) ; return $ this -> type_url === $ type_url ; } | This method returns whether the type_url in any_message is corresponded to the given class . |
44,620 | function loadString ( $ source ) { $ this -> setDimensions ( $ this -> max_x + 1 , $ this -> max_y + 1 ) ; $ this -> appendString ( $ source ) ; } | Load a string |
44,621 | function _newLine ( ) { while ( $ this -> y >= $ this -> max_y ) { $ this -> history = array_merge ( $ this -> history , array ( array_shift ( $ this -> screen ) ) ) ; $ this -> screen [ ] = '' ; $ this -> history_attrs = array_merge ( $ this -> history_attrs , array ( array_shift ( $ this -> attrs ) ) ) ; $ this -> attrs [ ] = $ this -> attr_row ; if ( count ( $ this -> history ) >= $ this -> max_history ) { array_shift ( $ this -> history ) ; array_shift ( $ this -> history_attrs ) ; } $ this -> y -- ; } $ this -> y ++ ; } | Add a new line |
44,622 | function _processCoordinate ( $ last_attr , $ cur_attr , $ char ) { $ output = '' ; if ( $ last_attr != $ cur_attr ) { $ close = $ open = '' ; if ( $ last_attr -> foreground != $ cur_attr -> foreground ) { if ( $ cur_attr -> foreground != 'white' ) { $ open .= '<span style="color: ' . $ cur_attr -> foreground . '">' ; } if ( $ last_attr -> foreground != 'white' ) { $ close = '</span>' . $ close ; } } if ( $ last_attr -> background != $ cur_attr -> background ) { if ( $ cur_attr -> background != 'black' ) { $ open .= '<span style="background: ' . $ cur_attr -> background . '">' ; } if ( $ last_attr -> background != 'black' ) { $ close = '</span>' . $ close ; } } if ( $ last_attr -> bold != $ cur_attr -> bold ) { if ( $ cur_attr -> bold ) { $ open .= '<b>' ; } else { $ close = '</b>' . $ close ; } } if ( $ last_attr -> underline != $ cur_attr -> underline ) { if ( $ cur_attr -> underline ) { $ open .= '<u>' ; } else { $ close = '</u>' . $ close ; } } if ( $ last_attr -> blink != $ cur_attr -> blink ) { if ( $ cur_attr -> blink ) { $ open .= '<blink>' ; } else { $ close = '</blink>' . $ close ; } } $ output .= $ close . $ open ; } $ output .= htmlspecialchars ( $ char ) ; return $ output ; } | Returns the current coordinate without preformating |
44,623 | function startSSHForwarding ( $ ssh ) { if ( $ this -> forward_status == self :: FORWARD_NONE ) { $ this -> forward_status = self :: FORWARD_REQUEST ; } } | Signal that agent forwarding should be requested when a channel is opened |
44,624 | function _request_forwarding ( $ ssh ) { $ request_channel = $ ssh -> _get_open_channel ( ) ; if ( $ request_channel === false ) { return false ; } $ packet = pack ( 'CNNa*C' , NET_SSH2_MSG_CHANNEL_REQUEST , $ ssh -> server_channels [ $ request_channel ] , strlen ( 'auth-agent-req@openssh.com' ) , 'auth-agent-req@openssh.com' , 1 ) ; $ ssh -> channel_status [ $ request_channel ] = NET_SSH2_MSG_CHANNEL_REQUEST ; if ( ! $ ssh -> _send_binary_packet ( $ packet ) ) { return false ; } $ response = $ ssh -> _get_channel_packet ( $ request_channel ) ; if ( $ response === false ) { return false ; } $ ssh -> channel_status [ $ request_channel ] = NET_SSH2_MSG_CHANNEL_OPEN ; $ this -> forward_status = self :: FORWARD_ACTIVE ; return true ; } | Request agent forwarding of remote server |
44,625 | function _forward_data ( $ data ) { if ( $ this -> expected_bytes > 0 ) { $ this -> socket_buffer .= $ data ; $ this -> expected_bytes -= strlen ( $ data ) ; } else { $ agent_data_bytes = current ( unpack ( 'N' , $ data ) ) ; $ current_data_bytes = strlen ( $ data ) ; $ this -> socket_buffer = $ data ; if ( $ current_data_bytes != $ agent_data_bytes + 4 ) { $ this -> expected_bytes = ( $ agent_data_bytes + 4 ) - $ current_data_bytes ; return false ; } } if ( strlen ( $ this -> socket_buffer ) != fwrite ( $ this -> fsock , $ this -> socket_buffer ) ) { user_error ( 'Connection closed attempting to forward data to SSH agent' ) ; } $ this -> socket_buffer = '' ; $ this -> expected_bytes = 0 ; $ agent_reply_bytes = current ( unpack ( 'N' , fread ( $ this -> fsock , 4 ) ) ) ; $ agent_reply_data = fread ( $ this -> fsock , $ agent_reply_bytes ) ; $ agent_reply_data = current ( unpack ( 'a*' , $ agent_reply_data ) ) ; return pack ( 'Na*' , $ agent_reply_bytes , $ agent_reply_data ) ; } | Forward data to SSH Agent and return data reply |
44,626 | public function setIdentifierValue ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> identifier_value = $ var ; $ this -> has_identifier_value = true ; return $ this ; } | The value of the uninterpreted option in whatever type the tokenizer identified it as during parsing . Exactly one of these should be set . |
44,627 | function _generate_identifier ( ) { $ identifier = 'SSH-2.0-phpseclib_2.0' ; $ ext = array ( ) ; if ( function_exists ( '\\Sodium\\library_version_major' ) ) { $ ext [ ] = 'libsodium' ; } if ( extension_loaded ( 'openssl' ) ) { $ ext [ ] = 'openssl' ; } elseif ( extension_loaded ( 'mcrypt' ) ) { $ ext [ ] = 'mcrypt' ; } if ( extension_loaded ( 'gmp' ) ) { $ ext [ ] = 'gmp' ; } elseif ( extension_loaded ( 'bcmath' ) ) { $ ext [ ] = 'bcmath' ; } if ( ! empty ( $ ext ) ) { $ identifier .= ' (' . implode ( ', ' , $ ext ) . ')' ; } return $ identifier ; } | Generates the SSH identifier |
44,628 | function _encryption_algorithm_to_crypt_instance ( $ algorithm ) { switch ( $ algorithm ) { case '3des-cbc' : return new TripleDES ( ) ; case '3des-ctr' : return new TripleDES ( Base :: MODE_CTR ) ; case 'aes256-cbc' : case 'aes192-cbc' : case 'aes128-cbc' : return new Rijndael ( ) ; case 'aes256-ctr' : case 'aes192-ctr' : case 'aes128-ctr' : return new Rijndael ( Base :: MODE_CTR ) ; case 'blowfish-cbc' : return new Blowfish ( ) ; case 'blowfish-ctr' : return new Blowfish ( Base :: MODE_CTR ) ; case 'twofish128-cbc' : case 'twofish192-cbc' : case 'twofish256-cbc' : case 'twofish-cbc' : return new Twofish ( ) ; case 'twofish128-ctr' : case 'twofish192-ctr' : case 'twofish256-ctr' : return new Twofish ( Base :: MODE_CTR ) ; case 'arcfour' : case 'arcfour128' : case 'arcfour256' : return new RC4 ( ) ; } return null ; } | Maps an encryption algorithm name to an instance of a subclass of \ phpseclib \ Crypt \ Base . |
44,629 | function _keyboard_interactive_login ( $ username , $ password ) { $ packet = pack ( 'CNa*Na*Na*Na*Na*' , NET_SSH2_MSG_USERAUTH_REQUEST , strlen ( $ username ) , $ username , strlen ( 'ssh-connection' ) , 'ssh-connection' , strlen ( 'keyboard-interactive' ) , 'keyboard-interactive' , 0 , '' , 0 , '' ) ; if ( ! $ this -> _send_binary_packet ( $ packet ) ) { return false ; } return $ this -> _keyboard_interactive_process ( $ password ) ; } | Login via keyboard - interactive authentication |
44,630 | function _ssh_agent_login ( $ username , $ agent ) { $ this -> agent = $ agent ; $ keys = $ agent -> requestIdentities ( ) ; foreach ( $ keys as $ key ) { if ( $ this -> _privatekey_login ( $ username , $ key ) ) { return true ; } } return false ; } | Login with an ssh - agent provided key |
44,631 | function _reset_connection ( $ reason ) { $ this -> _disconnect ( $ reason ) ; $ this -> decrypt = $ this -> encrypt = false ; $ this -> decrypt_block_size = $ this -> encrypt_block_size = 8 ; $ this -> hmac_check = $ this -> hmac_create = false ; $ this -> hmac_size = false ; $ this -> session_id = false ; $ this -> retry_connect = true ; $ this -> get_seq_no = $ this -> send_seq_no = 0 ; } | Resets a connection for re - use |
44,632 | function _close_channel ( $ client_channel , $ want_reply = false ) { $ this -> _send_binary_packet ( pack ( 'CN' , NET_SSH2_MSG_CHANNEL_EOF , $ this -> server_channels [ $ client_channel ] ) ) ; if ( ! $ want_reply ) { $ this -> _send_binary_packet ( pack ( 'CN' , NET_SSH2_MSG_CHANNEL_CLOSE , $ this -> server_channels [ $ client_channel ] ) ) ; } $ this -> channel_status [ $ client_channel ] = NET_SSH2_MSG_CHANNEL_CLOSE ; $ this -> curTimeout = 0 ; while ( ! is_bool ( $ this -> _get_channel_packet ( $ client_channel ) ) ) { } if ( $ want_reply ) { $ this -> _send_binary_packet ( pack ( 'CN' , NET_SSH2_MSG_CHANNEL_CLOSE , $ this -> server_channels [ $ client_channel ] ) ) ; } if ( $ this -> bitmap & self :: MASK_SHELL ) { $ this -> bitmap &= ~ self :: MASK_SHELL ; } } | Closes and flushes a channel |
44,633 | function _array_intersect_first ( $ array1 , $ array2 ) { foreach ( $ array1 as $ value ) { if ( in_array ( $ value , $ array2 ) ) { return $ value ; } } return false ; } | Returns the first value of the intersection of two arrays or false if the intersection is empty . The order is defined by the first parameter . |
44,634 | public function setReservedRange ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Internal \ EnumDescriptorProto \ EnumReservedRange :: class ) ; $ this -> reserved_range = $ arr ; $ this -> has_reserved_range = true ; return $ this ; } | Range of reserved numeric values . Reserved numeric values may not be used by enum values in the same enum declaration . Reserved ranges may not overlap . |
44,635 | public function setInputType ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> input_type = $ var ; $ this -> has_input_type = true ; return $ this ; } | Input and output type names . These are resolved in the same way as FieldDescriptorProto . type_name but must refer to a message type . |
44,636 | protected function executeRequest ( array $ httpHeaders , $ requestUrl , $ httpMethod , $ payload ) { $ result = [ ] ; $ ch = curl_init ( $ requestUrl ) ; curl_setopt_array ( $ ch , [ CURLOPT_HTTPHEADER => $ httpHeaders , CURLOPT_RETURNTRANSFER => true , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_SSL_VERIFYHOST => 0 , ] ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ httpMethod ) ; if ( $ payload instanceof Payload ) { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ payload -> getPayloadJSON ( ) ) ; } $ result [ 'response' ] = curl_exec ( $ ch ) ; $ result [ 'http_code' ] = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; if ( curl_error ( $ ch ) ) { throw new RequestException ( curl_error ( $ ch ) ) ; } curl_close ( $ ch ) ; return $ result ; } | Execute Request against the API . |
44,637 | public function offsetSet ( $ key , $ value ) { $ this -> checkKey ( $ this -> key_type , $ key ) ; switch ( $ this -> value_type ) { case GPBType :: SFIXED32 : case GPBType :: SINT32 : case GPBType :: INT32 : case GPBType :: ENUM : GPBUtil :: checkInt32 ( $ value ) ; break ; case GPBType :: FIXED32 : case GPBType :: UINT32 : GPBUtil :: checkUint32 ( $ value ) ; break ; case GPBType :: SFIXED64 : case GPBType :: SINT64 : case GPBType :: INT64 : GPBUtil :: checkInt64 ( $ value ) ; break ; case GPBType :: FIXED64 : case GPBType :: UINT64 : GPBUtil :: checkUint64 ( $ value ) ; break ; case GPBType :: FLOAT : GPBUtil :: checkFloat ( $ value ) ; break ; case GPBType :: DOUBLE : GPBUtil :: checkDouble ( $ value ) ; break ; case GPBType :: BOOL : GPBUtil :: checkBool ( $ value ) ; break ; case GPBType :: STRING : GPBUtil :: checkString ( $ value , true ) ; break ; case GPBType :: MESSAGE : if ( is_null ( $ value ) ) { trigger_error ( "Map element cannot be null." , E_USER_ERROR ) ; } GPBUtil :: checkMessage ( $ value , $ this -> klass ) ; break ; default : break ; } $ this -> container [ $ key ] = $ value ; } | Assign the element at the given key . |
44,638 | public function offsetUnset ( $ key ) { $ this -> checkKey ( $ this -> key_type , $ key ) ; unset ( $ this -> container [ $ key ] ) ; } | Remove the element at the given key . |
44,639 | public function offsetExists ( $ key ) { $ this -> checkKey ( $ this -> key_type , $ key ) ; return isset ( $ this -> container [ $ key ] ) ; } | Check the existence of the element at the given key . |
44,640 | public function setUninterpretedOption ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Internal \ UninterpretedOption :: class ) ; $ this -> uninterpreted_option = $ arr ; $ this -> has_uninterpreted_option = true ; return $ this ; } | The parser stores options it doesn t recognize here . See above . |
44,641 | function setPreferredEngine ( $ engine ) { if ( $ this -> mode_3cbc ) { $ this -> des [ 0 ] -> setPreferredEngine ( $ engine ) ; $ this -> des [ 1 ] -> setPreferredEngine ( $ engine ) ; $ this -> des [ 2 ] -> setPreferredEngine ( $ engine ) ; } return parent :: setPreferredEngine ( $ engine ) ; } | Sets the internal crypt engine |
44,642 | private function setAttributes ( ) { $ result = $ this -> rawResult ; AmlResult :: checkAttributes ( $ result ) ; $ this -> onPepList = ( bool ) $ result [ self :: ON_PEP_LIST_KEY ] ; $ this -> onFraudList = ( bool ) $ result [ self :: ON_FRAUD_LIST_KEY ] ; $ this -> onWatchList = ( bool ) $ result [ self :: ON_WATCH_LIST_KEY ] ; } | Set attribute values . |
44,643 | public static function checkAttributes ( array $ result ) { $ expectedAttributes = [ self :: ON_PEP_LIST_KEY , self :: ON_WATCH_LIST_KEY , self :: ON_WATCH_LIST_KEY , ] ; $ providedAttributes = array_keys ( $ result ) ; $ missingAttr = array_diff ( $ expectedAttributes , $ providedAttributes ) ; if ( ! empty ( $ missingAttr ) ) { throw new AmlException ( 'Missing attributes from the result: ' . implode ( ',' , $ missingAttr ) , 106 ) ; } } | Check if all the attributes are included in the result . |
44,644 | private function appendAgeVerifications ( array & $ attributesMap ) { $ ageVerificationConverter = new AgeVerificationConverter ( $ attributesMap ) ; $ ageVerifications = $ ageVerificationConverter -> getAgeVerificationsFromAttrsMap ( ) ; $ attributesMap [ Profile :: ATTR_AGE_VERIFICATIONS ] = $ ageVerifications ; } | Add age_verifications data to the attributesMap |
44,645 | function encodeDER ( $ source , $ mapping , $ special = array ( ) ) { $ this -> location = array ( ) ; return $ this -> _encode_der ( $ source , $ mapping , null , $ special ) ; } | ASN . 1 Encode |
44,646 | public function discardUnknownFields ( ) { $ this -> unknown = "" ; foreach ( $ this -> desc -> getField ( ) as $ field ) { if ( $ field -> getType ( ) != GPBType :: MESSAGE ) { continue ; } if ( $ field -> isMap ( ) ) { $ value_field = $ field -> getMessageType ( ) -> getFieldByNumber ( 2 ) ; if ( $ value_field -> getType ( ) != GPBType :: MESSAGE ) { continue ; } $ getter = $ field -> getGetter ( ) ; $ map = $ this -> $ getter ( ) ; foreach ( $ map as $ key => $ value ) { $ value -> discardUnknownFields ( ) ; } } else if ( $ field -> getLabel ( ) === GPBLabel :: REPEATED ) { $ getter = $ field -> getGetter ( ) ; $ arr = $ this -> $ getter ( ) ; foreach ( $ arr as $ sub ) { $ sub -> discardUnknownFields ( ) ; } } else if ( $ field -> getLabel ( ) === GPBLabel :: OPTIONAL ) { $ getter = $ field -> getGetter ( ) ; $ sub = $ this -> $ getter ( ) ; if ( ! is_null ( $ sub ) ) { $ sub -> discardUnknownFields ( ) ; } } } } | Clear all unknown fields previously parsed . |
44,647 | public function mergeFrom ( $ msg ) { if ( get_class ( $ this ) !== get_class ( $ msg ) ) { user_error ( "Cannot merge messages with different class." ) ; return ; } foreach ( $ this -> desc -> getField ( ) as $ field ) { $ setter = $ field -> getSetter ( ) ; $ getter = $ field -> getGetter ( ) ; if ( $ field -> isMap ( ) ) { if ( count ( $ msg -> $ getter ( ) ) != 0 ) { $ value_field = $ field -> getMessageType ( ) -> getFieldByNumber ( 2 ) ; foreach ( $ msg -> $ getter ( ) as $ key => $ value ) { if ( $ value_field -> getType ( ) == GPBType :: MESSAGE ) { $ klass = $ value_field -> getMessageType ( ) -> getClass ( ) ; $ copy = new $ klass ; $ copy -> mergeFrom ( $ value ) ; $ this -> kvUpdateHelper ( $ field , $ key , $ copy ) ; } else { $ this -> kvUpdateHelper ( $ field , $ key , $ value ) ; } } } } else if ( $ field -> getLabel ( ) === GPBLabel :: REPEATED ) { if ( count ( $ msg -> $ getter ( ) ) != 0 ) { foreach ( $ msg -> $ getter ( ) as $ tmp ) { if ( $ field -> getType ( ) == GPBType :: MESSAGE ) { $ klass = $ field -> getMessageType ( ) -> getClass ( ) ; $ copy = new $ klass ; $ copy -> mergeFrom ( $ tmp ) ; $ this -> appendHelper ( $ field , $ copy ) ; } else { $ this -> appendHelper ( $ field , $ tmp ) ; } } } } else if ( $ field -> getLabel ( ) === GPBLabel :: OPTIONAL ) { if ( $ msg -> $ getter ( ) !== $ this -> defaultValue ( $ field ) ) { $ tmp = $ msg -> $ getter ( ) ; if ( $ field -> getType ( ) == GPBType :: MESSAGE ) { if ( is_null ( $ this -> $ getter ( ) ) ) { $ klass = $ field -> getMessageType ( ) -> getClass ( ) ; $ new_msg = new $ klass ; $ this -> $ setter ( $ new_msg ) ; } $ this -> $ getter ( ) -> mergeFrom ( $ tmp ) ; } else { $ this -> $ setter ( $ tmp ) ; } } } } } | Merges the contents of the specified message into current message . |
44,648 | protected function mergeFromArray ( array $ array ) { foreach ( $ array as $ key => $ value ) { $ field = $ this -> desc -> getFieldByName ( $ key ) ; if ( is_null ( $ field ) ) { throw new \ UnexpectedValueException ( 'Invalid message property: ' . $ key ) ; } $ setter = $ field -> getSetter ( ) ; if ( $ field -> isMap ( ) ) { $ valueField = $ field -> getMessageType ( ) -> getFieldByName ( 'value' ) ; if ( ! is_null ( $ valueField ) && $ valueField -> isWrapperType ( ) ) { self :: normalizeArrayElementsToMessageType ( $ value , $ valueField -> getMessageType ( ) -> getClass ( ) ) ; } } elseif ( $ field -> isWrapperType ( ) ) { $ class = $ field -> getMessageType ( ) -> getClass ( ) ; if ( $ field -> isRepeated ( ) ) { self :: normalizeArrayElementsToMessageType ( $ value , $ class ) ; } else { self :: normalizeToMessageType ( $ value , $ class ) ; } } $ this -> $ setter ( $ value ) ; } } | Populates the message from a user - supplied PHP array . Array keys correspond to Message properties and nested message properties . |
44,649 | public function serializeToString ( ) { $ output = new CodedOutputStream ( $ this -> byteSize ( ) ) ; $ this -> serializeToStream ( $ output ) ; return $ output -> getData ( ) ; } | Serialize the message to string . |
44,650 | public function serializeToJsonString ( ) { $ output = new CodedOutputStream ( $ this -> jsonByteSize ( ) ) ; $ this -> serializeToJsonStream ( $ output ) ; return $ output -> getData ( ) ; } | Serialize the message to json string . |
44,651 | public function getAgeVerificationsFromAttrsMap ( ) { $ ageVerificationsArr = [ ] ; foreach ( $ this -> profileAttributesMap as $ attrName => $ attributeObj ) { foreach ( $ this -> getAgeProcessors ( ) as $ ageProcessorClass ) { $ abstractAgeProcessorClass = '\\Yoti\\Util\\Age\\AbstractAgeProcessor' ; if ( null !== $ attrName && null !== $ attributeObj && is_subclass_of ( $ ageProcessorClass , $ abstractAgeProcessorClass ) ) { $ ageProcessorObj = new $ ageProcessorClass ( $ attributeObj ) ; if ( $ ageVerification = $ ageProcessorObj -> process ( ) ) { $ ageVerificationsArr [ $ attrName ] = $ ageVerification ; } } } } return $ ageVerificationsArr ; } | Return list of age verification . |
44,652 | public function key ( ) { $ key = key ( $ this -> container ) ; if ( $ this -> key_type === GPBType :: BOOL ) { return boolval ( $ key ) ; } elseif ( $ this -> key_type === GPBType :: STRING ) { return strval ( $ key ) ; } else { return $ key ; } } | Return the current key . |
44,653 | function get ( $ remote_file , $ local_file = false ) { if ( ! isset ( $ this -> ssh ) ) { return false ; } if ( ! $ this -> ssh -> exec ( 'scp -f ' . escapeshellarg ( $ remote_file ) , false ) ) { return false ; } $ this -> _send ( "\0" ) ; if ( ! preg_match ( '#(?<perms>[^ ]+) (?<size>\d+) (?<name>.+)#' , rtrim ( $ this -> _receive ( ) ) , $ info ) ) { return false ; } $ this -> _send ( "\0" ) ; $ size = 0 ; if ( $ local_file !== false ) { $ fp = @ fopen ( $ local_file , 'wb' ) ; if ( ! $ fp ) { return false ; } } $ content = '' ; while ( $ size < $ info [ 'size' ] ) { $ data = $ this -> _receive ( ) ; $ size += strlen ( $ data ) ; if ( $ local_file === false ) { $ content .= $ data ; } else { fputs ( $ fp , $ data ) ; } } $ this -> _close ( ) ; if ( $ local_file !== false ) { fclose ( $ fp ) ; return true ; } return $ content ; } | Downloads a file from the SCP server . |
44,654 | function _send ( $ data ) { switch ( $ this -> mode ) { case self :: MODE_SSH2 : $ this -> ssh -> _send_channel_packet ( SSH2 :: CHANNEL_EXEC , $ data ) ; break ; case self :: MODE_SSH1 : $ data = pack ( 'CNa*' , NET_SSH1_CMSG_STDIN_DATA , strlen ( $ data ) , $ data ) ; $ this -> ssh -> _send_binary_packet ( $ data ) ; } } | Sends a packet to an SSH server |
44,655 | function _receive ( ) { switch ( $ this -> mode ) { case self :: MODE_SSH2 : return $ this -> ssh -> _get_channel_packet ( SSH2 :: CHANNEL_EXEC , true ) ; case self :: MODE_SSH1 : if ( ! $ this -> ssh -> bitmap ) { return false ; } while ( true ) { $ response = $ this -> ssh -> _get_binary_packet ( ) ; switch ( $ response [ SSH1 :: RESPONSE_TYPE ] ) { case NET_SSH1_SMSG_STDOUT_DATA : if ( strlen ( $ response [ SSH1 :: RESPONSE_DATA ] ) < 4 ) { return false ; } extract ( unpack ( 'Nlength' , $ response [ SSH1 :: RESPONSE_DATA ] ) ) ; return $ this -> ssh -> _string_shift ( $ response [ SSH1 :: RESPONSE_DATA ] , $ length ) ; case NET_SSH1_SMSG_STDERR_DATA : break ; case NET_SSH1_SMSG_EXITSTATUS : $ this -> ssh -> _send_binary_packet ( chr ( NET_SSH1_CMSG_EXIT_CONFIRMATION ) ) ; fclose ( $ this -> ssh -> fsock ) ; $ this -> ssh -> bitmap = 0 ; return false ; default : user_error ( 'Unknown packet received' , E_USER_NOTICE ) ; return false ; } } } } | Receives a packet from an SSH server |
44,656 | function _close ( ) { switch ( $ this -> mode ) { case self :: MODE_SSH2 : $ this -> ssh -> _close_channel ( SSH2 :: CHANNEL_EXEC , true ) ; break ; case self :: MODE_SSH1 : $ this -> ssh -> disconnect ( ) ; } } | Closes the connection to an SSH server |
44,657 | public function offsetSet ( $ offset , $ value ) { switch ( $ this -> type ) { case GPBType :: SFIXED32 : case GPBType :: SINT32 : case GPBType :: INT32 : case GPBType :: ENUM : GPBUtil :: checkInt32 ( $ value ) ; break ; case GPBType :: FIXED32 : case GPBType :: UINT32 : GPBUtil :: checkUint32 ( $ value ) ; break ; case GPBType :: SFIXED64 : case GPBType :: SINT64 : case GPBType :: INT64 : GPBUtil :: checkInt64 ( $ value ) ; break ; case GPBType :: FIXED64 : case GPBType :: UINT64 : GPBUtil :: checkUint64 ( $ value ) ; break ; case GPBType :: FLOAT : GPBUtil :: checkFloat ( $ value ) ; break ; case GPBType :: DOUBLE : GPBUtil :: checkDouble ( $ value ) ; break ; case GPBType :: BOOL : GPBUtil :: checkBool ( $ value ) ; break ; case GPBType :: BYTES : GPBUtil :: checkString ( $ value , false ) ; break ; case GPBType :: STRING : GPBUtil :: checkString ( $ value , true ) ; break ; case GPBType :: MESSAGE : if ( is_null ( $ value ) ) { trigger_error ( "RepeatedField element cannot be null." , E_USER_ERROR ) ; } GPBUtil :: checkMessage ( $ value , $ this -> klass ) ; break ; default : break ; } if ( is_null ( $ offset ) ) { $ this -> container [ ] = $ value ; } else { $ count = count ( $ this -> container ) ; if ( ! is_numeric ( $ offset ) || $ offset < 0 || $ offset >= $ count ) { trigger_error ( "Cannot modify element at the given index" , E_USER_ERROR ) ; return ; } $ this -> container [ $ offset ] = $ value ; } } | Assign the element at the given index . |
44,658 | public function offsetUnset ( $ offset ) { $ count = count ( $ this -> container ) ; if ( ! is_numeric ( $ offset ) || $ count === 0 || $ offset !== $ count - 1 ) { trigger_error ( "Cannot remove element at the given index" , E_USER_ERROR ) ; return ; } array_pop ( $ this -> container ) ; } | Remove the element at the given index . |
44,659 | public function getActivityDetails ( $ encryptedConnectToken = null ) { if ( ! $ encryptedConnectToken && array_key_exists ( 'token' , $ _GET ) ) { $ encryptedConnectToken = $ _GET [ 'token' ] ; } $ receipt = $ this -> getReceipt ( $ encryptedConnectToken ) ; if ( $ receipt -> getSharingOutcome ( ) !== self :: OUTCOME_SUCCESS ) { throw new ActivityDetailsException ( 'Outcome was unsuccessful' , 502 ) ; } return new ActivityDetails ( $ receipt , $ this -> pemContent ) ; } | Return Yoti user profile . |
44,660 | public function performAmlCheck ( AmlProfile $ amlProfile ) { $ amlPayload = new Payload ( $ amlProfile -> getData ( ) ) ; $ result = $ this -> sendRequest ( self :: AML_CHECK_ENDPOINT , CurlRequestHandler :: METHOD_POST , $ amlPayload ) ; $ responseArr = json_decode ( $ result [ 'response' ] , true ) ; $ this -> checkJsonError ( ) ; $ this -> validateResult ( $ responseArr , $ result [ 'http_code' ] ) ; return new AmlResult ( $ responseArr ) ; } | Perform AML profile check . |
44,661 | protected function sendRequest ( $ endpoint , $ httpMethod , Payload $ payload = null ) { return $ this -> requestHandler -> sendRequest ( $ endpoint , $ httpMethod , $ payload ) ; } | Make REST request to Connect API . This method allows to stub the request call in test mode . |
44,662 | private function validateResult ( array $ responseArr , $ httpCode ) { $ httpCode = ( int ) $ httpCode ; if ( $ httpCode === 200 ) { return ; } $ errorMessage = $ this -> getErrorMessage ( $ responseArr ) ; $ errorCode = isset ( $ responseArr [ 'code' ] ) ? $ responseArr [ 'code' ] : 'Error' ; if ( ! empty ( $ errorMessage ) ) { throw new AmlException ( "$errorCode - {$errorMessage}" , $ httpCode ) ; } throw new AmlException ( "{$errorCode} - Server responded with {$httpCode}" , $ httpCode ) ; } | Handle request result . |
44,663 | private function getErrorMessage ( array $ result ) { $ errorMessage = '' ; if ( isset ( $ result [ 'errors' ] [ 0 ] [ 'property' ] ) && isset ( $ result [ 'errors' ] [ 0 ] [ 'message' ] ) ) { $ errorMessage = $ result [ 'errors' ] [ 0 ] [ 'property' ] . ': ' . $ result [ 'errors' ] [ 0 ] [ 'message' ] ; } return $ errorMessage ; } | Get error message from the response array . |
44,664 | private function getReceipt ( $ encryptedConnectToken , $ httpMethod = CurlRequestHandler :: METHOD_GET , $ payload = null ) { $ token = $ this -> decryptConnectToken ( $ encryptedConnectToken ) ; if ( ! $ token ) { throw new ActivityDetailsException ( 'Could not decrypt connect token.' , 401 ) ; } $ endpoint = sprintf ( self :: PROFILE_REQUEST_ENDPOINT , $ token ) ; $ result = $ this -> sendRequest ( $ endpoint , $ httpMethod , $ payload ) ; $ responseArr = $ this -> processResult ( $ result ) ; $ this -> checkForReceipt ( $ responseArr ) ; return new Receipt ( $ responseArr [ 'receipt' ] ) ; } | Decrypt and return receipt data . |
44,665 | private function decryptConnectToken ( $ encryptedConnectToken ) { $ tok = base64_decode ( strtr ( $ encryptedConnectToken , '-_,' , '+/=' ) ) ; openssl_private_decrypt ( $ tok , $ token , $ this -> pemContent ) ; return $ token ; } | Decrypt connect token . |
44,666 | private function extractPemContent ( & $ pem ) { if ( ! $ pem ) { throw new YotiClientException ( 'PEM file is required' , 400 ) ; } if ( strpos ( $ pem , 'file://' ) !== false && ! file_exists ( $ pem ) ) { throw new YotiClientException ( 'PEM file was not found.' , 400 ) ; } if ( file_exists ( $ pem ) ) { $ pem = file_get_contents ( $ pem ) ; } if ( ! openssl_get_privatekey ( $ pem ) ) { throw new YotiClientException ( 'PEM key content is invalid' , 400 ) ; } } | Validate and return PEM file content . |
44,667 | public function setSourceFile ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> source_file = $ var ; $ this -> has_source_file = true ; return $ this ; } | Identifies the filesystem path to the original source . proto . |
44,668 | private function generateRequestHeaders ( $ signedMessage ) { $ requestHeaders = [ CurlRequestHandler :: YOTI_AUTH_HEADER_KEY . ": {$this->authKey}" , CurlRequestHandler :: YOTI_DIGEST_HEADER_KEY . ": {$signedMessage}" , CurlRequestHandler :: YOTI_SDK_IDENTIFIER_KEY . ": {$this->sdkIdentifier}" , 'Content-Type: application/json' , 'Accept: application/json' , ] ; if ( $ version = Config :: getInstance ( ) -> get ( 'version' ) ) { $ requestHeaders [ ] = self :: YOTI_SDK_VERSION . ": {$this->sdkIdentifier}-{$version}" ; } return $ requestHeaders ; } | Return the request headers including the signed message . |
44,669 | private static function methodIsAllowed ( $ httpMethod ) { $ allowedMethods = [ self :: METHOD_GET , self :: METHOD_POST , self :: METHOD_PUT , self :: METHOD_PATCH , self :: METHOD_DELETE , ] ; return in_array ( $ httpMethod , $ allowedMethods , true ) ; } | Check the HTTP method is allowed . |
44,670 | function _openssl_ofb_process ( $ plaintext , & $ encryptIV , & $ buffer ) { if ( strlen ( $ buffer [ 'xor' ] ) ) { $ ciphertext = $ plaintext ^ $ buffer [ 'xor' ] ; $ buffer [ 'xor' ] = substr ( $ buffer [ 'xor' ] , strlen ( $ ciphertext ) ) ; $ plaintext = substr ( $ plaintext , strlen ( $ ciphertext ) ) ; } else { $ ciphertext = '' ; } $ block_size = $ this -> block_size ; $ len = strlen ( $ plaintext ) ; $ key = $ this -> key ; $ overflow = $ len % $ block_size ; if ( strlen ( $ plaintext ) ) { if ( $ overflow ) { $ ciphertext .= openssl_encrypt ( substr ( $ plaintext , 0 , - $ overflow ) . str_repeat ( "\0" , $ block_size ) , $ this -> cipher_name_openssl , $ key , $ this -> openssl_options , $ encryptIV ) ; $ xor = $ this -> _string_pop ( $ ciphertext , $ block_size ) ; if ( $ this -> continuousBuffer ) { $ encryptIV = $ xor ; } $ ciphertext .= $ this -> _string_shift ( $ xor , $ overflow ) ^ substr ( $ plaintext , - $ overflow ) ; if ( $ this -> continuousBuffer ) { $ buffer [ 'xor' ] = $ xor ; } } else { $ ciphertext = openssl_encrypt ( $ plaintext , $ this -> cipher_name_openssl , $ key , $ this -> openssl_options , $ encryptIV ) ; if ( $ this -> continuousBuffer ) { $ encryptIV = substr ( $ ciphertext , - $ block_size ) ^ substr ( $ plaintext , - $ block_size ) ; } } } return $ ciphertext ; } | OpenSSL OFB Processor |
44,671 | function _pad ( $ text ) { $ length = strlen ( $ text ) ; if ( ! $ this -> padding ) { if ( $ length % $ this -> block_size == 0 ) { return $ text ; } else { user_error ( "The plaintext's length ($length) is not a multiple of the block size ({$this->block_size})" ) ; $ this -> padding = true ; } } $ pad = $ this -> block_size - ( $ length % $ this -> block_size ) ; return str_pad ( $ text , $ length + $ pad , chr ( $ pad ) ) ; } | Pads a string |
44,672 | function _unpad ( $ text ) { if ( ! $ this -> padding ) { return $ text ; } $ length = ord ( $ text [ strlen ( $ text ) - 1 ] ) ; if ( ! $ length || $ length > $ this -> block_size ) { return false ; } return substr ( $ text , 0 , - $ length ) ; } | Unpads a string . |
44,673 | function _clearBuffers ( ) { $ this -> enbuffer = $ this -> debuffer = array ( 'ciphertext' => '' , 'xor' => '' , 'pos' => 0 , 'enmcrypt_init' => true ) ; $ this -> encryptIV = $ this -> decryptIV = str_pad ( substr ( $ this -> iv , 0 , $ this -> block_size ) , $ this -> block_size , "\0" ) ; if ( ! $ this -> skip_key_adjustment ) { $ this -> key = str_pad ( substr ( $ this -> key , 0 , $ this -> key_length ) , $ this -> key_length , "\0" ) ; } } | Clears internal buffers |
44,674 | function _increment_str ( & $ var ) { for ( $ i = 4 ; $ i <= strlen ( $ var ) ; $ i += 4 ) { $ temp = substr ( $ var , - $ i , 4 ) ; switch ( $ temp ) { case "\xFF\xFF\xFF\xFF" : $ var = substr_replace ( $ var , "\x00\x00\x00\x00" , - $ i , 4 ) ; break ; case "\x7F\xFF\xFF\xFF" : $ var = substr_replace ( $ var , "\x80\x00\x00\x00" , - $ i , 4 ) ; return ; default : $ temp = unpack ( 'Nnum' , $ temp ) ; $ var = substr_replace ( $ var , pack ( 'N' , $ temp [ 'num' ] + 1 ) , - $ i , 4 ) ; return ; } } $ remainder = strlen ( $ var ) % 4 ; if ( $ remainder == 0 ) { return ; } $ temp = unpack ( 'Nnum' , str_pad ( substr ( $ var , 0 , $ remainder ) , 4 , "\0" , STR_PAD_LEFT ) ) ; $ temp = substr ( pack ( 'N' , $ temp [ 'num' ] + 1 ) , - $ remainder ) ; $ var = substr_replace ( $ var , $ temp , 0 , $ remainder ) ; } | Increment the current string |
44,675 | public function setJavaPackage ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> java_package = $ var ; $ this -> has_java_package = true ; return $ this ; } | Sets the Java package where classes generated from this . proto will be placed . By default the proto package is used but this is often inappropriate because proto packages do not normally start with backwards domain names . |
44,676 | public function setObjcClassPrefix ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> objc_class_prefix = $ var ; $ this -> has_objc_class_prefix = true ; return $ this ; } | Sets the objective c class prefix which is prepended to all objective c generated classes from this . proto . There is no default . |
44,677 | public function setCsharpNamespace ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> csharp_namespace = $ var ; $ this -> has_csharp_namespace = true ; return $ this ; } | Namespace for generated classes ; defaults to the package . |
44,678 | public function setPhpClassPrefix ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> php_class_prefix = $ var ; $ this -> has_php_class_prefix = true ; return $ this ; } | Sets the php class prefix which is prepended to all php generated classes from this . proto . Default is empty . |
44,679 | public function setPhpNamespace ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> php_namespace = $ var ; $ this -> has_php_namespace = true ; return $ this ; } | Use this option to change the namespace of php generated classes . Default is empty . When this option is empty the package name will be used for determining the namespace . |
44,680 | public function setPhpMetadataNamespace ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> php_metadata_namespace = $ var ; $ this -> has_php_metadata_namespace = true ; return $ this ; } | Use this option to change the namespace of php generated metadata classes . Default is empty . When this option is empty the proto file name will be used for determining the namespace . |
44,681 | public function setRubyPackage ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> ruby_package = $ var ; $ this -> has_ruby_package = true ; return $ this ; } | Use this option to change the package of ruby generated classes . Default is empty . When this option is not set the package name will be used for determining the ruby package . |
44,682 | protected function isDerivedAttribute ( Attribute $ attribute ) { return preg_match ( $ this -> getAgePattern ( ) , $ attribute -> getName ( ) ) ? true : false ; } | Return true if attribute name matches the pattern . |
44,683 | protected function createAgeVerification ( Attribute $ attribute ) { $ ageCheckArr = explode ( static :: AGE_DELIMITER , $ attribute -> getName ( ) ) ; if ( count ( $ ageCheckArr ) > 1 ) { $ result = $ attribute -> getValue ( ) === 'true' ? true : false ; $ checkType = $ ageCheckArr [ 0 ] ; $ age = ( int ) $ ageCheckArr [ 1 ] ; return new AgeVerification ( $ attribute , $ checkType , $ age , $ result ) ; } return null ; } | This method could be overridden by a child class . Depending on the parsing process and complexity . |
44,684 | public function process ( ) { if ( $ this -> isDerivedAttribute ( $ this -> attribute ) ) { return $ this -> createAgeVerification ( $ this -> attribute ) ; } return null ; } | Process derived attribute . |
44,685 | public static function convertToYotiAttributesMap ( AttributeList $ attributeList ) { $ yotiAttributes = [ ] ; foreach ( $ attributeList -> getAttributes ( ) as $ attr ) { $ attrName = $ attr -> getName ( ) ; if ( null === $ attrName ) { continue ; } $ yotiAttributes [ $ attr -> getName ( ) ] = AttributeConverter :: convertToYotiAttribute ( $ attr ) ; } return $ yotiAttributes ; } | Convert Protobuf AttributeList to Yoti Attributes map . |
44,686 | public static function convertToProtobufAttributeList ( $ encryptedData , $ wrappedReceiptKey , $ pem ) { $ decryptedCipherText = self :: decryptCipherText ( $ encryptedData , $ wrappedReceiptKey , $ pem ) ; $ attributeList = new \ Attrpubapi \ AttributeList ( ) ; $ attributeList -> mergeFromString ( $ decryptedCipherText ) ; return $ attributeList ; } | Return Protobuf AttributeList . |
44,687 | private static function decryptCipherText ( $ encryptedData , $ wrappedReceiptKey , $ pem ) { openssl_private_decrypt ( base64_decode ( $ wrappedReceiptKey ) , $ unwrappedKey , $ pem ) ; $ cipherText = openssl_decrypt ( $ encryptedData -> getCipherText ( ) , 'aes-256-cbc' , $ unwrappedKey , OPENSSL_RAW_DATA , $ encryptedData -> getIv ( ) ) ; return $ cipherText ; } | Return decrypted cipher text . |
44,688 | function _safe_divide ( $ x , $ y ) { if ( self :: $ base === 26 ) { return ( int ) ( $ x / $ y ) ; } return ( $ x - ( $ x % $ y ) ) / $ y ; } | Single digit division |
44,689 | public function setAnnotation ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Internal \ GeneratedCodeInfo \ Annotation :: class ) ; $ this -> annotation = $ arr ; $ this -> has_annotation = true ; return $ this ; } | An Annotation connects some span of text in generated code to an element of its generating . proto file . |
44,690 | public static function signRequest ( AbstractRequestHandler $ requestHandler , $ endpoint , $ httpMethod , Payload $ payload = null ) { $ endPointPath = self :: generateEndPointPath ( $ endpoint , $ requestHandler -> getSDKId ( ) ) ; $ messageToSign = "{$httpMethod}&$endPointPath" ; if ( $ payload instanceof Payload ) { $ messageToSign .= "&{$payload->getBase64Payload()}" ; } openssl_sign ( $ messageToSign , $ signedMessage , $ requestHandler -> getPem ( ) , OPENSSL_ALGO_SHA256 ) ; self :: validateSignedMessage ( $ signedMessage ) ; $ base64SignedMessage = base64_encode ( $ signedMessage ) ; return [ self :: SIGNED_MESSAGE_KEY => $ base64SignedMessage , self :: END_POINT_PATH_KEY => $ endPointPath ] ; } | Return request signed data . |
44,691 | public function setDependency ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> dependency = $ arr ; $ this -> has_dependency = true ; return $ this ; } | Names of files imported by this file . |
44,692 | public function setPublicDependency ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: INT32 ) ; $ this -> public_dependency = $ arr ; $ this -> has_public_dependency = true ; return $ this ; } | Indexes of the public imported files in the dependency list above . |
44,693 | public function setWeakDependency ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: INT32 ) ; $ this -> weak_dependency = $ arr ; $ this -> has_weak_dependency = true ; return $ this ; } | Indexes of the weak imported files in the dependency list . For Google - internal migration only . Do not use . |
44,694 | public function setMessageType ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Internal \ DescriptorProto :: class ) ; $ this -> message_type = $ arr ; $ this -> has_message_type = true ; return $ this ; } | All top - level definitions in this file . |
44,695 | public function setSyntax ( $ var ) { GPBUtil :: checkString ( $ var , True ) ; $ this -> syntax = $ var ; $ this -> has_syntax = true ; return $ this ; } | The syntax of the proto file . The supported values are proto2 and proto3 . |
44,696 | public function parseAttribute ( $ attributeName , $ pem ) { $ data = $ this -> getAttribute ( $ attributeName ) ; $ encryptedData = AttributeConverter :: getEncryptedData ( $ data ) ; return AttributeListConverter :: convertToProtobufAttributeList ( $ encryptedData , $ this -> getWrappedReceiptKey ( ) , $ pem ) ; } | Return Protobuf Attributes List . |
44,697 | function _mapOutExtensions ( & $ root , $ path , $ asn1 ) { $ extensions = & $ this -> _subArray ( $ root , $ path ) ; if ( is_array ( $ extensions ) ) { $ size = count ( $ extensions ) ; for ( $ i = 0 ; $ i < $ size ; $ i ++ ) { if ( $ extensions [ $ i ] instanceof Element ) { continue ; } $ id = $ extensions [ $ i ] [ 'extnId' ] ; $ value = & $ extensions [ $ i ] [ 'extnValue' ] ; switch ( $ id ) { case 'id-ce-certificatePolicies' : for ( $ j = 0 ; $ j < count ( $ value ) ; $ j ++ ) { if ( ! isset ( $ value [ $ j ] [ 'policyQualifiers' ] ) ) { continue ; } for ( $ k = 0 ; $ k < count ( $ value [ $ j ] [ 'policyQualifiers' ] ) ; $ k ++ ) { $ subid = $ value [ $ j ] [ 'policyQualifiers' ] [ $ k ] [ 'policyQualifierId' ] ; $ map = $ this -> _getMapping ( $ subid ) ; $ subvalue = & $ value [ $ j ] [ 'policyQualifiers' ] [ $ k ] [ 'qualifier' ] ; if ( $ map !== false ) { $ subvalue = new Element ( $ asn1 -> encodeDER ( $ subvalue , $ map ) ) ; } } } break ; case 'id-ce-authorityKeyIdentifier' : if ( isset ( $ value [ 'authorityCertSerialNumber' ] ) ) { if ( $ value [ 'authorityCertSerialNumber' ] -> toBytes ( ) == '' ) { $ temp = chr ( ( ASN1 :: CLASS_CONTEXT_SPECIFIC << 6 ) | 2 ) . "\1\0" ; $ value [ 'authorityCertSerialNumber' ] = new Element ( $ temp ) ; } } } $ map = $ this -> _getMapping ( $ id ) ; if ( is_bool ( $ map ) ) { if ( ! $ map ) { user_error ( $ id . ' is not a currently supported extension' ) ; unset ( $ extensions [ $ i ] ) ; } } else { $ temp = $ asn1 -> encodeDER ( $ value , $ map , array ( 'iPAddress' => array ( $ this , '_encodeIP' ) ) ) ; $ value = base64_encode ( $ temp ) ; } } } } | Map extension values from extension - specific internal format to octet string . |
44,698 | function _mapInDNs ( & $ root , $ path , $ asn1 ) { $ dns = & $ this -> _subArray ( $ root , $ path ) ; if ( is_array ( $ dns ) ) { for ( $ i = 0 ; $ i < count ( $ dns ) ; $ i ++ ) { for ( $ j = 0 ; $ j < count ( $ dns [ $ i ] ) ; $ j ++ ) { $ type = $ dns [ $ i ] [ $ j ] [ 'type' ] ; $ value = & $ dns [ $ i ] [ $ j ] [ 'value' ] ; if ( is_object ( $ value ) && $ value instanceof Element ) { $ map = $ this -> _getMapping ( $ type ) ; if ( ! is_bool ( $ map ) ) { $ decoded = $ asn1 -> decodeBER ( $ value ) ; $ value = $ asn1 -> asn1map ( $ decoded [ 0 ] , $ map ) ; } } } } } } | Map DN values from ANY type to DN - specific internal format . |
44,699 | function validateURL ( $ url ) { if ( ! is_array ( $ this -> currentCert ) || ! isset ( $ this -> currentCert [ 'tbsCertificate' ] ) ) { return false ; } $ components = parse_url ( $ url ) ; if ( ! isset ( $ components [ 'host' ] ) ) { return false ; } if ( $ names = $ this -> getExtension ( 'id-ce-subjectAltName' ) ) { foreach ( $ names as $ name ) { foreach ( $ name as $ key => $ value ) { $ value = str_replace ( array ( '.' , '*' ) , array ( '\.' , '[^.]*' ) , $ value ) ; switch ( $ key ) { case 'dNSName' : if ( preg_match ( '#^' . $ value . '$#' , $ components [ 'host' ] ) ) { return true ; } break ; case 'iPAddress' : if ( preg_match ( '#(?:\d{1-3}\.){4}#' , $ components [ 'host' ] . '.' ) && preg_match ( '#^' . $ value . '$#' , $ components [ 'host' ] ) ) { return true ; } } } } return false ; } if ( $ value = $ this -> getDNProp ( 'id-at-commonName' ) ) { $ value = str_replace ( array ( '.' , '*' ) , array ( '\.' , '[^.]*' ) , $ value [ 0 ] ) ; return preg_match ( '#^' . $ value . '$#' , $ components [ 'host' ] ) ; } return false ; } | Validate an X . 509 certificate against a URL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.