Documentation

PKCS8 extends PKCS8
in package

AbstractYes

PKCS#8 Formatted RSA Key Handler

Tags
author

Jim Wigginton terrafrost@php.net

access

public

Table of Contents

Constants

MODE_ANY  = 0
Auto-detect the format
MODE_DER  = 2
Require raw DER's be supplied
MODE_PEM  = 1
Require base64-encoded PEM's be supplied
OID_NAME  = 'rsaEncryption'
OID Name
OID_VALUE  = '1.2.840.113549.1.1.1'
OID Value

Properties

$childOIDsLoaded  : bool
Child OIDs loaded
$format  : int
Is the key a base-64 encoded PEM, DER or should it be auto-detected?
$defaultEncryptionAlgorithm  : string
Default encryption algorithm
$defaultEncryptionScheme  : string
Default encryption scheme
$defaultIterationCount  : int
Default Iteration Count
$defaultPRF  : string
Default PRF
$oidsLoaded  : bool
OIDs loaded

Methods

extractEncryptionAlgorithm()  : array<string|int, mixed>
Returns the encryption parameters used by the key
load()  : array<string|int, mixed>
Break a public or private key down into its constituent components
requireAny()  : mixed
Accept any format and auto detect the format
requireDER()  : mixed
Require raw DER's be supplied
requirePEM()  : mixed
Require base64-encoded PEM's be supplied
savePrivateKey()  : string
Convert a private key to the appropriate format.
savePublicKey()  : string
Convert a public key to the appropriate format
setEncryptionAlgorithm()  : mixed
Sets the default encryption algorithm
setEncryptionScheme()  : mixed
Sets the default encryption algorithm for PBES2
setIterationCount()  : mixed
Sets the iteration count
setPRF()  : mixed
Sets the PRF for PBES2
wrapPrivateKey()  : string
Wrap a private key appropriately
wrapPublicKey()  : string
Wrap a public key appropriately
getPBES1EncryptionObject()  : SymmetricKey
Returns a SymmetricKey object based on a PBES1 $algo
getPBES1Hash()  : string
Returns a hash based on a PBES1 $algo
getPBES1KDF()  : string
Returns a KDF baesd on a PBES1 $algo
getPBES2EncryptionObject()  : SymmetricKey
Returns a SymmetricKey object baesd on a PBES2 $algo
initialize_static_variables()  : mixed
Initialize static variables
preParse()  : array<string|int, mixed>
Perform some preliminary parsing of the key

Constants

MODE_ANY

Auto-detect the format

public mixed MODE_ANY = 0

MODE_DER

Require raw DER's be supplied

public mixed MODE_DER = 2

MODE_PEM

Require base64-encoded PEM's be supplied

public mixed MODE_PEM = 1

OID_NAME

OID Name

public string OID_NAME = 'rsaEncryption'
Tags
access

private

OID_VALUE

OID Value

public string OID_VALUE = '1.2.840.113549.1.1.1'
Tags
access

private

Properties

$childOIDsLoaded

Child OIDs loaded

protected static bool $childOIDsLoaded = false
Tags
access

private

$format

Is the key a base-64 encoded PEM, DER or should it be auto-detected?

protected static int $format = self::MODE_ANY
Tags
access

private

$defaultEncryptionAlgorithm

Default encryption algorithm

private static string $defaultEncryptionAlgorithm = 'id-PBES2'
Tags
access

private

$defaultEncryptionScheme

Default encryption scheme

private static string $defaultEncryptionScheme = 'aes128-CBC-PAD'

Only used when defaultEncryptionAlgorithm is id-PBES2

Tags
access

private

$defaultIterationCount

Default Iteration Count

private static int $defaultIterationCount = 2048
Tags
access

private

$defaultPRF

Default PRF

private static string $defaultPRF = 'id-hmacWithSHA256'

Only used when defaultEncryptionAlgorithm is id-PBES2

Tags
access

private

$oidsLoaded

OIDs loaded

private static bool $oidsLoaded = false
Tags
access

private

Methods

extractEncryptionAlgorithm()

Returns the encryption parameters used by the key

public static extractEncryptionAlgorithm(string $key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed>

load()

Break a public or private key down into its constituent components

public static load(string $key[, string $password = '' ]) : array<string|int, mixed>
Parameters
$key : string
$password : string = ''

optional

Tags
access

public

Return values
array<string|int, mixed>

requireAny()

Accept any format and auto detect the format

public static requireAny() : mixed

This is the default setting

Tags
access

public

requireDER()

Require raw DER's be supplied

public static requireDER() : mixed
Tags
access

public

requirePEM()

Require base64-encoded PEM's be supplied

public static requirePEM() : mixed
Tags
access

public

savePrivateKey()

Convert a private key to the appropriate format.

public static savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array<string|int, mixed> $primes, array<string|int, mixed> $exponents, array<string|int, mixed> $coefficients[, string $password = '' ][, array<string|int, mixed> $options = [] ]) : string
Parameters
$n : BigInteger
$e : BigInteger
$d : BigInteger
$primes : array<string|int, mixed>
$exponents : array<string|int, mixed>
$coefficients : array<string|int, mixed>
$password : string = ''

optional

$options : array<string|int, mixed> = []

optional

Tags
access

public

Return values
string

savePublicKey()

Convert a public key to the appropriate format

public static savePublicKey(BigInteger $n, BigInteger $e[, array<string|int, mixed> $options = [] ]) : string
Parameters
$n : BigInteger
$e : BigInteger
$options : array<string|int, mixed> = []

optional

Tags
access

public

Return values
string

setEncryptionAlgorithm()

Sets the default encryption algorithm

public static setEncryptionAlgorithm(string $algo) : mixed
Parameters
$algo : string
Tags
access

public

setEncryptionScheme()

Sets the default encryption algorithm for PBES2

public static setEncryptionScheme(string $algo) : mixed
Parameters
$algo : string
Tags
access

public

setIterationCount()

Sets the iteration count

public static setIterationCount(int $count) : mixed
Parameters
$count : int
Tags
access

public

setPRF()

Sets the PRF for PBES2

public static setPRF(string $algo) : mixed
Parameters
$algo : string
Tags
access

public

wrapPrivateKey()

Wrap a private key appropriately

protected static wrapPrivateKey(string $key, string $attr, mixed $params, string $password[, string $oid = null ][, string $publicKey = '' ][, array<string|int, mixed> $options = [] ]) : string
Parameters
$key : string
$attr : string
$params : mixed
$password : string
$oid : string = null

optional

$publicKey : string = ''

optional

$options : array<string|int, mixed> = []

optional

Tags
access

public

Return values
string

wrapPublicKey()

Wrap a public key appropriately

protected static wrapPublicKey(string $key, mixed $params[, string $oid = null ]) : string
Parameters
$key : string
$params : mixed
$oid : string = null
Tags
access

public

Return values
string

getPBES1EncryptionObject()

Returns a SymmetricKey object based on a PBES1 $algo

private static getPBES1EncryptionObject(string $algo) : SymmetricKey
Parameters
$algo : string
Tags
access

public

Return values
SymmetricKey

getPBES1Hash()

Returns a hash based on a PBES1 $algo

private static getPBES1Hash(string $algo) : string
Parameters
$algo : string
Tags
access

public

Return values
string

getPBES1KDF()

Returns a KDF baesd on a PBES1 $algo

private static getPBES1KDF(string $algo) : string
Parameters
$algo : string
Tags
access

public

Return values
string

getPBES2EncryptionObject()

Returns a SymmetricKey object baesd on a PBES2 $algo

private static getPBES2EncryptionObject(string $algo) : SymmetricKey
Parameters
$algo : string
Tags
access

public

Return values
SymmetricKey

initialize_static_variables()

Initialize static variables

private static initialize_static_variables() : mixed
Tags
access

private

preParse()

Perform some preliminary parsing of the key

private static preParse(string &$key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed>

        
On this page

Search results