idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
18,600
public function genUid ( ) { $ rand = $ this [ 'crypt/rand' ] ; $ hex = bin2hex ( $ rand -> Bytes ( 32 ) ) ; $ str = substr ( $ hex , 0 , 16 ) . '-' . substr ( $ hex , 16 , 8 ) . '-' . substr ( $ hex , 24 , 8 ) . '-' . substr ( $ hex , 32 , 8 ) . '-' . substr ( $ hex , 40 , 24 ) ; return $ str ; }
Returns a unique identifier .
18,601
public function bytes ( $ len ) { $ strong = false ; if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ rnd = openssl_random_pseudo_bytes ( $ len , $ strong ) ; if ( $ strong === true ) { return $ rnd ; } } if ( function_exists ( 'mcrypt_create_iv' ) ) { $ rnd = mcrypt_create_iv ( $ len , MCRYPT_DEV_URANDOM )...
Generate pseudorandom bytes .
18,602
public function arrayRand ( $ array , $ num = 1 ) { $ keys = array_keys ( $ array ) ; $ numKeys = sizeof ( $ keys ) ; if ( $ num == 1 ) { return $ keys [ $ this -> int ( 0 , $ numKeys - 1 ) ] ; } for ( $ i = 0 ; $ i < $ num ; $ i ++ ) { $ picked [ ] = $ keys [ $ this -> int ( 0 , $ numKeys - 1 ) ] ; } return $ picked ;...
Return one or more random random keys from an array .
18,603
public function withSubject ( Name $ subject ) : self { $ obj = clone $ this ; $ obj -> _subject = $ subject ; return $ obj ; }
Get self with subject .
18,604
public function withExtensionRequest ( Extensions $ extensions ) : self { $ obj = clone $ this ; if ( ! isset ( $ obj -> _attributes ) ) { $ obj -> _attributes = new Attributes ( ) ; } $ obj -> _attributes = $ obj -> _attributes -> withUnique ( Attribute :: fromAttributeValues ( new ExtensionRequestValue ( $ extensions...
Get self with extension request attribute .
18,605
public function sign ( SignatureAlgorithmIdentifier $ algo , PrivateKeyInfo $ privkey_info , Crypto $ crypto = null ) : CertificationRequest { $ crypto = $ crypto ? : Crypto :: getDefault ( ) ; $ data = $ this -> toASN1 ( ) -> toDER ( ) ; $ signature = $ crypto -> sign ( $ data , $ privkey_info , $ algo ) ; return new ...
Create signed CertificationRequest .
18,606
public static function fromAttributeValues ( AttributeValue ... $ values ) : self { $ attribs = array_map ( function ( AttributeValue $ value ) { return $ value -> toAttribute ( ) ; } , $ values ) ; return new self ( ... $ attribs ) ; }
Initialize from attribute values .
18,607
public function roles ( ) : array { return array_merge ( array ( ) , ... array_map ( function ( Attribute $ attr ) { return $ attr -> values ( ) ; } , $ this -> allOf ( AttributeType :: OID_ROLE ) ) ) ; }
Get all Role attribute values .
18,608
public function withPolicyAuthority ( GeneralNames $ names ) : self { $ obj = clone $ this ; $ obj -> _policyAuthority = $ names ; return $ obj ; }
Get self with policy authority .
18,609
public function isHeldBy ( Certificate $ cert ) : bool { if ( ! $ this -> _acinfo -> holder ( ) -> identifiesPKC ( $ cert ) ) { return false ; } return true ; }
Check whether attribute certificate is issued to the subject identified by given public key certificate .
18,610
public function isIssuedBy ( Certificate $ cert ) : bool { if ( ! $ this -> _acinfo -> issuer ( ) -> identifiesPKC ( $ cert ) ) { return false ; } return true ; }
Check whether attribute certificate is issued by given public key certificate .
18,611
public static function fromString ( string $ role_name , GeneralNames $ authority = null ) : self { return new self ( new UniformResourceIdentifier ( $ role_name ) , $ authority ) ; }
Initialize from a role string .
18,612
public function validate ( ) : AttributeCertificate { $ this -> _validateHolder ( ) ; $ issuer = $ this -> _verifyIssuer ( ) ; $ this -> _validateIssuerProfile ( $ issuer ) ; $ this -> _validateTime ( ) ; $ this -> _validateTargeting ( ) ; return $ this -> _ac ; }
Validate attribute certificate .
18,613
private function _validateHolder ( ) : Certificate { $ path = $ this -> _config -> holderPath ( ) ; $ config = PathValidationConfig :: defaultConfig ( ) -> withMaxLength ( count ( $ path ) ) -> withDateTime ( $ this -> _config -> evaluationTime ( ) ) ; try { $ holder = $ path -> validate ( $ config , $ this -> _crypto ...
Validate AC holder s certification .
18,614
private function _verifyIssuer ( ) : Certificate { $ path = $ this -> _config -> issuerPath ( ) ; $ config = PathValidationConfig :: defaultConfig ( ) -> withMaxLength ( count ( $ path ) ) -> withDateTime ( $ this -> _config -> evaluationTime ( ) ) ; try { $ issuer = $ path -> validate ( $ config , $ this -> _crypto ) ...
Verify AC s signature and issuer s certification .
18,615
private function _validateIssuerProfile ( Certificate $ cert ) { $ exts = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ exts -> hasKeyUsage ( ) && ! $ exts -> keyUsage ( ) -> isDigitalSignature ( ) ) { throw new ACValidationException ( "Issuer PKC's Key Usage extension doesn't permit" . " verification of digi...
Validate AC issuer s profile .
18,616
private function _validateTime ( ) { $ t = $ this -> _config -> evaluationTime ( ) ; $ validity = $ this -> _ac -> acinfo ( ) -> validityPeriod ( ) ; if ( $ validity -> notBeforeTime ( ) -> diff ( $ t ) -> invert ) { throw new ACValidationException ( "Validity period has not started." ) ; } if ( $ t -> diff ( $ validit...
Validate AC s validity period .
18,617
private function _validateTargeting ( ) { $ exts = $ this -> _ac -> acinfo ( ) -> extensions ( ) ; if ( ! $ exts -> has ( Extension :: OID_TARGET_INFORMATION ) ) { return ; } $ ext = $ exts -> get ( Extension :: OID_TARGET_INFORMATION ) ; if ( $ ext instanceof TargetInformationExtension && ! $ this -> _hasMatchingTarge...
Validate AC s target information .
18,618
private function _hasMatchingTarget ( Targets $ targets ) : bool { foreach ( $ this -> _config -> targets ( ) as $ target ) { if ( $ targets -> hasTarget ( $ target ) ) { return true ; } } return false ; }
Check whether validation configuration has matching targets .
18,619
private function parseDsn ( $ dsn ) { $ parsed = array ( ) ; $ typeEnd = strpos ( $ dsn , ':' ) ; $ dbType = substr ( $ dsn , 0 , $ typeEnd ) ; $ parsed [ 'dbtype' ] = $ dbType ; $ dsn = substr ( $ dsn , $ typeEnd + 1 ) ; $ parts = explode ( ';' , $ dsn ) ; foreach ( $ parts as $ part ) { list ( $ key , $ val ) = explo...
Extract configuration variables from the DSN .
18,620
public static function fromPKC ( Certificate $ cert ) : IssuerSerial { $ tbsCert = $ cert -> tbsCertificate ( ) ; $ issuer = new GeneralNames ( new DirectoryName ( $ tbsCert -> issuer ( ) ) ) ; $ serial = $ tbsCert -> serialNumber ( ) ; $ uid = $ tbsCert -> hasIssuerUniqueID ( ) ? $ tbsCert -> issuerUniqueID ( ) : null...
Initialize from a public key certificate .
18,621
public function identifiesPKC ( Certificate $ cert ) : bool { $ tbs = $ cert -> tbsCertificate ( ) ; if ( ! $ tbs -> issuer ( ) -> equals ( $ this -> _issuer -> firstDN ( ) ) ) { return false ; } if ( strval ( $ tbs -> serialNumber ( ) ) != strval ( $ this -> _serial ) ) { return false ; } if ( $ this -> _issuerUID && ...
Check whether this IssuerSerial identifies given certificate .
18,622
private function _checkUniqueID ( Certificate $ cert ) : bool { if ( ! $ cert -> tbsCertificate ( ) -> hasIssuerUniqueID ( ) ) { return false ; } $ uid = $ cert -> tbsCertificate ( ) -> issuerUniqueID ( ) -> string ( ) ; if ( $ this -> _issuerUID -> string ( ) != $ uid ) { return false ; } return true ; }
Check whether issuerUID matches given certificate .
18,623
public function hasChildWithValidPolicy ( string $ oid ) : bool { foreach ( $ this -> _children as $ node ) { if ( $ node -> validPolicy ( ) == $ oid ) { return true ; } } return false ; }
Check whether node has a child node with given valid policy OID .
18,624
public function addChild ( PolicyNode $ node ) : self { $ id = spl_object_hash ( $ node ) ; $ node -> _parent = $ this ; $ this -> _children [ $ id ] = $ node ; return $ this ; }
Add child node .
18,625
public function remove ( ) : self { if ( $ this -> _parent ) { $ id = spl_object_hash ( $ this ) ; unset ( $ this -> _parent -> _children [ $ id ] ) ; unset ( $ this -> _parent ) ; } return $ this ; }
Remove this node from the tree .
18,626
public function parents ( ) : array { if ( ! $ this -> _parent ) { return array ( ) ; } $ nodes = $ this -> _parent -> parents ( ) ; $ nodes [ ] = $ this -> _parent ; return array_reverse ( $ nodes ) ; }
Get chain of parent nodes from this node s parent to the root node .
18,627
public function walkNodes ( callable $ fn ) { foreach ( $ this -> _children as $ node ) { $ node -> walkNodes ( $ fn ) ; } $ fn ( $ this ) ; }
Walk tree from this node applying a callback for each node .
18,628
public function nodeCount ( ) : int { $ c = 1 ; foreach ( $ this -> _children as $ child ) { $ c += $ child -> nodeCount ( ) ; } return $ c ; }
Get the total number of nodes in a tree .
18,629
public static function fromCSR ( CertificationRequest $ cr ) : self { $ cri = $ cr -> certificationRequestInfo ( ) ; $ tbs_cert = new self ( $ cri -> subject ( ) , $ cri -> subjectPKInfo ( ) , new Name ( ) , Validity :: fromStrings ( null , null ) ) ; if ( $ cri -> hasAttributes ( ) ) { $ attribs = $ cri -> attributes ...
Initialize from certification request .
18,630
public function withIssuerCertificate ( Certificate $ cert ) : self { $ obj = clone $ this ; $ obj -> _issuer = $ cert -> tbsCertificate ( ) -> subject ( ) ; $ key_id = $ cert -> tbsCertificate ( ) -> subjectPublicKeyInfo ( ) -> keyIdentifier ( ) ; $ obj -> _extensions = $ obj -> _extensions -> withExtensions ( new Aut...
Get self with fields set from the issuer s certificate .
18,631
public function withVersion ( int $ version ) : self { $ obj = clone $ this ; $ obj -> _version = $ version ; return $ obj ; }
Get self with given version .
18,632
public function withIssuer ( Name $ issuer ) : self { $ obj = clone $ this ; $ obj -> _issuer = $ issuer ; return $ obj ; }
Get self with given issuer .
18,633
public function withValidity ( Validity $ validity ) : self { $ obj = clone $ this ; $ obj -> _validity = $ validity ; return $ obj ; }
Get self with given validity .
18,634
public function withSubjectPublicKeyInfo ( PublicKeyInfo $ pub_key_info ) : self { $ obj = clone $ this ; $ obj -> _subjectPublicKeyInfo = $ pub_key_info ; return $ obj ; }
Get self with given subject public key info .
18,635
public function withIssuerUniqueID ( UniqueIdentifier $ id ) : self { $ obj = clone $ this ; $ obj -> _issuerUniqueID = $ id ; return $ obj ; }
Get self with issuer unique ID .
18,636
public function withSubjectUniqueID ( UniqueIdentifier $ id ) : self { $ obj = clone $ this ; $ obj -> _subjectUniqueID = $ id ; return $ obj ; }
Get self with subject unique ID .
18,637
public function sign ( SignatureAlgorithmIdentifier $ algo , PrivateKeyInfo $ privkey_info , Crypto $ crypto = null ) : Certificate { $ crypto = $ crypto ? : Crypto :: getDefault ( ) ; $ tbs_cert = clone $ this ; if ( ! isset ( $ tbs_cert -> _version ) ) { $ tbs_cert -> _version = $ tbs_cert -> _determineVersion ( ) ; ...
Create signed certificate .
18,638
protected function _determineVersion ( ) : int { if ( count ( $ this -> _extensions ) ) { return self :: VERSION_3 ; } if ( isset ( $ this -> _issuerUniqueID ) || isset ( $ this -> _subjectUniqueID ) ) { return self :: VERSION_2 ; } return self :: VERSION_1 ; }
Determine minimum version for the certificate .
18,639
public function gc ( $ ttl ) { $ store = $ this -> psl [ 'store' ] ; $ Ids = $ store -> listIds ( 'session' ) ; foreach ( $ Ids as $ Id ) { $ data = $ store -> meta ( 'session' , $ Id ) ; if ( $ data -> time + $ ttl < time ( ) ) { $ store -> delete ( 'session' , $ Id ) ; } } return true ; }
Do garbage collection .
18,640
public function open ( $ path , $ name ) { $ rand = $ this -> psl [ 'crypt/rand' ] ; $ this -> savePath = $ path ; $ this -> name = $ name ; $ this -> keyCookie = $ name . '_secret' ; if ( isset ( $ _COOKIE [ $ name ] ) ) { $ this -> currID = $ _COOKIE [ $ name ] ; } else { $ this -> currID = null ; } if ( $ this -> se...
Open a session .
18,641
public function read ( $ id ) { $ crypto = $ this -> psl [ 'crypt/crypto' ] ; $ store = $ this -> psl [ 'store' ] ; if ( ! isset ( $ _COOKIE [ $ this -> name ] ) ) { return false ; } try { $ sessData = $ store -> read ( 'session' , $ _COOKIE [ $ this -> name ] ) ; if ( $ sessData !== false ) { $ return = $ crypto -> de...
Read and decrypt a session .
18,642
public function write ( $ id , $ data ) { $ crypto = $ this -> psl [ 'crypt/crypto' ] ; $ store = $ this -> psl [ 'store' ] ; try { $ crypto -> _algo = $ this -> cryptAlgo ; $ crypto -> _mode = $ this -> cryptMode ; $ encrypted = $ crypto -> encrypt ( $ data , $ this -> secret ) ; if ( $ this -> newID != $ this -> curr...
Encrypt and save a session .
18,643
public function setSecret ( ) { $ rand = $ this -> psl [ 'crypt/rand' ] ; $ this -> secret = $ rand -> bytes ( 32 ) ; $ cookieParam = session_get_cookie_params ( ) ; setcookie ( $ this -> keyCookie , base64_encode ( $ this -> secret ) , $ cookieParam [ 'lifetime' ] , $ cookieParam [ 'path' ] , $ cookieParam [ 'domain' ...
Set the cookie with the secret .
18,644
public static function fromPEMs ( PEM ... $ pems ) : self { $ certs = array_map ( function ( PEM $ pem ) { return Certificate :: fromPEM ( $ pem ) ; } , $ pems ) ; return new self ( ... $ certs ) ; }
Initialize from a list of PEMs .
18,645
public static function fromPEMString ( string $ str ) : self { $ pems = PEMBundle :: fromString ( $ str ) -> all ( ) ; return self :: fromPEMs ( ... $ pems ) ; }
Initialize from a string containing multiple PEM blocks .
18,646
public function trustAnchorCertificate ( ) : Certificate { if ( ! count ( $ this -> _certs ) ) { throw new \ LogicException ( "No certificates." ) ; } return $ this -> _certs [ count ( $ this -> _certs ) - 1 ] ; }
Get the trust anchor certificate .
18,647
public function toPEMString ( ) : string { return implode ( "\n" , array_map ( function ( Certificate $ cert ) { return $ cert -> toPEM ( ) -> string ( ) ; } , $ this -> _certs ) ) ; }
Convert certificate chain to string of PEM blocks .
18,648
public function verify ( Crypto $ crypto = null ) : bool { $ crypto = $ crypto ? : Crypto :: getDefault ( ) ; $ data = $ this -> _certificationRequestInfo -> toASN1 ( ) -> toDER ( ) ; $ pk_info = $ this -> _certificationRequestInfo -> subjectPKInfo ( ) ; return $ crypto -> verify ( $ data , $ this -> _signature , $ pk_...
Verify certification request signature .
18,649
public static function fromTaggedType ( TaggedType $ el ) : self { switch ( $ el -> tag ( ) ) { case self :: TAG_FULL_NAME : return new FullName ( GeneralNames :: fromASN1 ( $ el -> asImplicit ( Element :: TYPE_SEQUENCE ) -> asSequence ( ) ) ) ; case self :: TAG_RDN : return new RelativeName ( RDN :: fromASN1 ( $ el ->...
Initialize from TaggedType .
18,650
public function flattenedMappings ( ) : array { $ mappings = array ( ) ; foreach ( $ this -> _mappings as $ mapping ) { $ idp = $ mapping -> issuerDomainPolicy ( ) ; if ( ! isset ( $ mappings [ $ idp ] ) ) { $ mappings [ $ idp ] = array ( ) ; } array_push ( $ mappings [ $ idp ] , $ mapping -> subjectDomainPolicy ( ) ) ...
Get mappings flattened into a single array of arrays of subject domains keyed by issuer domain .
18,651
public function issuerMappings ( string $ oid ) : array { $ oids = array ( ) ; foreach ( $ this -> _mappings as $ mapping ) { if ( $ mapping -> issuerDomainPolicy ( ) == $ oid ) { $ oids [ ] = $ mapping -> subjectDomainPolicy ( ) ; } } return $ oids ; }
Get all subject domain policy OIDs that are mapped to given issuer domain policy OID .
18,652
public function issuerDomainPolicies ( ) : array { $ idps = array_map ( function ( PolicyMapping $ mapping ) { return $ mapping -> issuerDomainPolicy ( ) ; } , $ this -> _mappings ) ; return array_values ( array_unique ( $ idps ) ) ; }
Get all mapped issuer domain policy OIDs .
18,653
public function hasAnyPolicyMapping ( ) : bool { foreach ( $ this -> _mappings as $ mapping ) { if ( $ mapping -> issuerDomainPolicy ( ) == PolicyInformation :: OID_ANY_POLICY ) { return true ; } if ( $ mapping -> subjectDomainPolicy ( ) == PolicyInformation :: OID_ANY_POLICY ) { return true ; } } return false ; }
Check whether policy mappings have anyPolicy mapped .
18,654
public function targets ( ) : Targets { if ( ! isset ( $ this -> _merged ) ) { $ a = array ( ) ; foreach ( $ this -> _targets as $ targets ) { $ a = array_merge ( $ a , $ targets -> all ( ) ) ; } $ this -> _merged = new Targets ( ... $ a ) ; } return $ this -> _merged ; }
Get all targets .
18,655
private function fillDictionaryWords ( ) { foreach ( $ this -> dictionary as $ w ) : $ this -> dictionaryWords [ ] = is_array ( $ w ) ? $ w [ 0 ] : $ w ; endforeach ; }
Fill the variable with only the words of the dictionary without the original word rules
18,656
public function setDictionaryFromFile ( $ path ) { if ( file_exists ( $ path ) ) { $ dict = include $ path ; if ( is_array ( $ dict ) ) { $ this -> dictionary = $ dict ; $ this -> fillDictionaryWords ( ) ; return $ this ; } throw new \ Exception ( 'The file content must be an array!' ) ; } throw new \ Exception ( 'File...
Set the bad words list from a file
18,657
public function setText ( $ text ) { $ this -> textOriginal = $ text ; $ this -> text = preg_replace ( "/([^\w ]*)/iu" , "" , $ text ) ; return $ this ; }
Set the text to be checked
18,658
public function check ( ) { foreach ( $ this -> dictionary as $ word ) : $ rule = "alone" ; if ( is_array ( $ word ) ) { $ rule = isset ( $ word [ 1 ] ) ? $ word [ 1 ] : $ rule ; $ word = $ word [ 0 ] ; } $ word = preg_replace ( "/([^\w ]*)/iu" , "" , $ word ) ; if ( "among" === $ rule ) { if ( preg_match ( "/(" . $ wo...
Checks for bad words in the text but verifies each dictionary word rule like alone ou among each word in the text .
18,659
public function create ( $ str ) { $ rand = $ this -> psl [ 'crypt/rand' ] ; $ crypto = $ this -> psl [ 'crypt/crypto' ] ; switch ( $ this -> method ) { case self :: BCRYPT : $ saltRnd = $ rand -> str ( 22 , $ this -> charsets [ 'itoa64' ] ) ; $ salt = sprintf ( '%s%s$%s' , self :: BCRYPT , $ this -> bcrypt_cost , $ sa...
Creates a salted hash from a string .
18,660
public function check ( $ str , $ hash ) { $ crypto = $ this -> psl [ 'crypt/crypto' ] ; $ compare = $ this -> psl [ 'string/compare' ] ; $ hashInfo = $ this -> getInfo ( $ hash ) ; switch ( $ hashInfo [ 'algo' ] ) { case self :: PBKDF2 : $ param = array ( ) ; list ( , , $ params , $ hash , $ salt ) = explode ( '$' , $...
Check a string against a hash .
18,661
public function getInfo ( $ hash ) { $ regex_pattern = '/^\$[a-z, 1-6]{1,6}\$/i' ; preg_match ( $ regex_pattern , $ hash , $ matches ) ; if ( sizeof ( $ matches ) > 0 ) { list ( $ method ) = $ matches ; } else { $ method = null ; } switch ( $ method ) { case self :: SHA256 : case self :: SHA512 : case self :: PBKDF2 : ...
Returns settings used to generate a hash .
18,662
public function withMaxLength ( int $ length ) : self { $ obj = clone $ this ; $ obj -> _maxLength = $ length ; return $ obj ; }
Get self with maximum path length .
18,663
public function withDateTime ( \ DateTimeImmutable $ dt ) : self { $ obj = clone $ this ; $ obj -> _dateTime = $ dt ; return $ obj ; }
Get self with reference date and time .
18,664
public function withTrustAnchor ( Certificate $ ca ) : self { $ obj = clone $ this ; $ obj -> _trustAnchor = $ ca ; return $ obj ; }
Get self with trust anchor certificate .
18,665
public function withPolicyMappingInhibit ( bool $ flag ) : self { $ obj = clone $ this ; $ obj -> _policyMappingInhibit = $ flag ; return $ obj ; }
Get self with initial - policy - mapping - inhibit set .
18,666
public function withExplicitPolicy ( bool $ flag ) : self { $ obj = clone $ this ; $ obj -> _explicitPolicy = $ flag ; return $ obj ; }
Get self with initial - explicit - policy set .
18,667
public function withAnyPolicyInhibit ( bool $ flag ) : self { $ obj = clone $ this ; $ obj -> _anyPolicyInhibit = $ flag ; return $ obj ; }
Get self with initial - any - policy - inhibit set .
18,668
public function withPolicySet ( string ... $ policies ) : self { $ obj = clone $ this ; $ obj -> _policySet = $ policies ; return $ obj ; }
Get self with user - initial - policy - set set to policy OIDs .
18,669
public function verify ( $ otp , $ secret ) { $ timeTick = $ this -> getTimestamp ( ) ; $ storeId = $ this -> getStoreId ( $ secret ) ; try { $ store = $ this -> psl [ 'store' ] -> read ( 'google-auth' , $ storeId ) ; for ( $ tick = $ timeTick - $ this -> _deviate ; $ tick <= $ timeTick + $ this -> _deviate ; $ tick ++...
Verify a OTP token .
18,670
public function getToken ( $ secret , $ timeTick = null ) { $ base32 = $ this -> psl [ 'string/base32' ] ; $ secret = $ base32 -> decode ( $ secret ) ; if ( $ timeTick === null ) { $ timeTick = $ this -> getTimestamp ( ) ; } $ timestamp = pack ( 'N*' , 0 ) . pack ( 'N*' , $ timeTick ) ; $ hash = hash_hmac ( 'sha1' , $ ...
Generate a OTP from a secret and time .
18,671
public function get ( string $ oid ) : Ext \ Extension { if ( ! $ this -> has ( $ oid ) ) { throw new \ LogicException ( "No extension by OID $oid." ) ; } return $ this -> _extensions [ $ oid ] ; }
Get extension by OID .
18,672
public function authorityKeyIdentifier ( ) : Ext \ AuthorityKeyIdentifierExtension { $ keyIdentifier = $ this -> get ( Ext \ Extension :: OID_AUTHORITY_KEY_IDENTIFIER ) ; return $ keyIdentifier ; }
Get Authority Key Identifier extension .
18,673
public function subjectKeyIdentifier ( ) : Ext \ SubjectKeyIdentifierExtension { $ subjectKeyIdentifier = $ this -> get ( Ext \ Extension :: OID_SUBJECT_KEY_IDENTIFIER ) ; return $ subjectKeyIdentifier ; }
Get Subject Key Identifier extension .
18,674
public function keyUsage ( ) : Ext \ KeyUsageExtension { $ keyUsage = $ this -> get ( Ext \ Extension :: OID_KEY_USAGE ) ; return $ keyUsage ; }
Get Key Usage extension .
18,675
public function certificatePolicies ( ) : Ext \ CertificatePoliciesExtension { $ certPolicies = $ this -> get ( Ext \ Extension :: OID_CERTIFICATE_POLICIES ) ; return $ certPolicies ; }
Get Certificate Policies extension .
18,676
public function policyMappings ( ) : Ext \ PolicyMappingsExtension { $ policyMappings = $ this -> get ( Ext \ Extension :: OID_POLICY_MAPPINGS ) ; return $ policyMappings ; }
Get Policy Mappings extension .
18,677
public function subjectAlternativeName ( ) : Ext \ SubjectAlternativeNameExtension { $ subjectAltName = $ this -> get ( Ext \ Extension :: OID_SUBJECT_ALT_NAME ) ; return $ subjectAltName ; }
Get Subject Alternative Name extension .
18,678
public function issuerAlternativeName ( ) : Ext \ IssuerAlternativeNameExtension { $ issuerAltName = $ this -> get ( Ext \ Extension :: OID_ISSUER_ALT_NAME ) ; return $ issuerAltName ; }
Get Issuer Alternative Name extension .
18,679
public function basicConstraints ( ) : Ext \ BasicConstraintsExtension { $ basicConstraints = $ this -> get ( Ext \ Extension :: OID_BASIC_CONSTRAINTS ) ; return $ basicConstraints ; }
Get Basic Constraints extension .
18,680
public function nameConstraints ( ) : Ext \ NameConstraintsExtension { $ nameConstraints = $ this -> get ( Ext \ Extension :: OID_NAME_CONSTRAINTS ) ; return $ nameConstraints ; }
Get Name Constraints extension .
18,681
public function policyConstraints ( ) : Ext \ PolicyConstraintsExtension { $ policyConstraints = $ this -> get ( Ext \ Extension :: OID_POLICY_CONSTRAINTS ) ; return $ policyConstraints ; }
Get Policy Constraints extension .
18,682
public function extendedKeyUsage ( ) : Ext \ ExtendedKeyUsageExtension { $ keyUsage = $ this -> get ( Ext \ Extension :: OID_EXT_KEY_USAGE ) ; return $ keyUsage ; }
Get Extended Key Usage extension .
18,683
public function crlDistributionPoints ( ) : Ext \ CRLDistributionPointsExtension { $ crlDist = $ this -> get ( Ext \ Extension :: OID_CRL_DISTRIBUTION_POINTS ) ; return $ crlDist ; }
Get CRL Distribution Points extension .
18,684
public function inhibitAnyPolicy ( ) : Ext \ InhibitAnyPolicyExtension { $ inhibitAny = $ this -> get ( Ext \ Extension :: OID_INHIBIT_ANY_POLICY ) ; return $ inhibitAny ; }
Get Inhibit anyPolicy extension .
18,685
public function decode ( $ str ) { $ str = strtoupper ( $ str ) ; $ l = strlen ( $ str ) ; $ n = 0 ; $ b = 0 ; $ decoded = null ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { $ n = $ n << 5 ; $ n = $ n + $ this -> decodeTable [ $ str [ $ i ] ] ; $ b = $ b + 5 ; if ( $ b >= 8 ) { $ b = $ b - 8 ; $ decoded .= chr ( ( $ n & ( 0...
Decode a Base32 encoded string .
18,686
public function get ( string $ oid ) : PolicyQualifierInfo { if ( ! $ this -> has ( $ oid ) ) { throw new \ LogicException ( "No $oid qualifier." ) ; } return $ this -> _qualifiers [ $ oid ] ; }
Get qualifier by OID .
18,687
private static function _createDateTime ( $ time = null , $ tz = null ) : \ DateTimeImmutable { if ( ! isset ( $ time ) ) { $ time = 'now' ; } if ( ! isset ( $ tz ) ) { $ tz = date_default_timezone_get ( ) ; } try { $ dt = new \ DateTimeImmutable ( $ time , self :: _createTimeZone ( $ tz ) ) ; return self :: _roundDown...
Create DateTime object from time string and timezone .
18,688
private static function _roundDownFractionalSeconds ( \ DateTimeImmutable $ dt ) : \ DateTimeImmutable { return \ DateTimeImmutable :: createFromFormat ( "Y-m-d H:i:s" , $ dt -> format ( "Y-m-d H:i:s" ) , $ dt -> getTimezone ( ) ) ; }
Rounds a \ DateTimeImmutable value such that fractional seconds are removed .
18,689
private static function _createTimeZone ( string $ tz ) : \ DateTimeZone { try { return new \ DateTimeZone ( $ tz ) ; } catch ( \ Exception $ e ) { throw new \ UnexpectedValueException ( "Invalid timezone." , 0 , $ e ) ; } }
Create DateTimeZone object from string .
18,690
public function run ( $ cmd , $ args = array ( ) , $ stdin = null ) { $ cmd = $ this -> buildCommand ( $ cmd , $ args ) ; $ process = proc_open ( $ cmd , $ this -> descSpecs , $ pipes , $ this -> _cwd , $ this -> _env ) ; if ( is_resource ( $ process ) ) { fwrite ( $ pipes [ self :: STDIN ] , $ stdin ) ; fclose ( $ pip...
Execute an external program .
18,691
private function buildCommand ( $ cmd , $ args = array ( ) ) { while ( list ( $ name , $ data ) = each ( $ args ) ) { $ safeData = false ; $ filterType = mb_substr ( $ name , 0 , 1 ) ; switch ( $ filterType ) { case '%' : $ safeData = escapeshellarg ( $ data ) ; break ; case '!' : $ safeData = escapeshellcmd ( $ data )...
Builds a command that is safe to execute .
18,692
public static function toTarget ( Certificate $ target , CertificateBundle $ trust_anchors , CertificateBundle $ intermediate = null ) : self { $ builder = new CertificationPathBuilder ( $ trust_anchors ) ; return $ builder -> shortestPathToTarget ( $ target , $ intermediate ) ; }
Build certification path to given target .
18,693
public static function fromTrustAnchorToTarget ( Certificate $ trust_anchor , Certificate $ target , CertificateBundle $ intermediate = null ) : self { return self :: toTarget ( $ target , new CertificateBundle ( $ trust_anchor ) , $ intermediate ) ; }
Build certification path from given trust anchor to target certificate using intermediate certificates from given bundle .
18,694
public function endEntityCertificate ( ) : Certificate { if ( ! count ( $ this -> _certificates ) ) { throw new \ LogicException ( "No certificates." ) ; } return $ this -> _certificates [ count ( $ this -> _certificates ) - 1 ] ; }
Get the end - entity certificate from the path .
18,695
public function startsWith ( Certificate ... $ certs ) : bool { $ n = count ( $ certs ) ; if ( $ n > count ( $ this -> _certificates ) ) { return false ; } for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { if ( ! $ certs [ $ i ] -> equals ( $ this -> _certificates [ $ i ] ) ) { return false ; } } return true ; }
Check whether certification path starts with one ore more given certificates in parameter order .
18,696
public function processPolicies ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ policies = $ cert -> tbsCertificate ( ) -> extensions ( ) -> certificatePolicies ( ) ; $ tree = clone $ this ; foreach ( $ policies as $ policy ) { if ( $ policy -> isAnyPolicy ( ) ) { $ tree -> _processAnyPolicy ( $ po...
Process policy information from the certificate .
18,697
public function processMappings ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ tree = clone $ this ; if ( $ state -> policyMapping ( ) > 0 ) { $ tree -> _applyMappings ( $ cert , $ state ) ; } else if ( $ state -> policyMapping ( ) == 0 ) { $ tree -> _deleteMappings ( $ cert , $ state ) ; } if ( !...
Process policy mappings from the certificate .
18,698
public function calculateIntersection ( ValidatorState $ state , array $ policies ) : ValidatorState { $ tree = clone $ this ; $ valid_policy_node_set = $ tree -> _validPolicyNodeSet ( ) ; $ valid_policy_node_set = array_filter ( $ valid_policy_node_set , function ( PolicyNode $ node ) use ( $ policies ) { if ( $ node ...
Calculate policy intersection as specified in Wrap - Up Procedure 6 . 1 . 5 . g .
18,699
public function policiesAtDepth ( int $ i ) : array { $ policies = array ( ) ; foreach ( $ this -> _nodesAtDepth ( $ i ) as $ node ) { $ policies [ ] = new PolicyInformation ( $ node -> validPolicy ( ) , ... $ node -> qualifiers ( ) ) ; } return $ policies ; }
Get policies at given policy tree depth .