openssl_open

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

openssl_open — 봉인된 데이터 열기


설명

openssl_open(
    string $data,
    string &$output,
    string $encrypted_key,
    OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key,
    string $cipher_algo,
    ?string $iv = null
): bool
                

openssl_open()은 키 식별자 private_key 및 봉투 키 encrypted_key와 연결된 개인 키를 사용하여 data를 열고(해독) output을 복호화된 데이터로 채웁니다. 봉투 키는 데이터가 봉인될 때 생성되며 하나의 특정 개인 키에서만 사용할 수 있습니다. 자세한 내용은 openssl_seal()을 참조하십시오.


매개변수

data
output
호출이 성공하면 열린 데이터가 이 매개변수에 반환됩니다.
encrypted_key
private_key
cipher_algo
암호 메서드.

주의 기본값('RC4')은 안전하지 않은 것으로 간주됩니다. 보안 암호 메서드를 명시적으로 지정하는 것이 좋습니다.

iv
초기화 벡터입니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


변경 로그

버전 설명
8.0.0 private_key는 이제 OpenSSLAsymmetricKey 또는 OpenSSLCertificate 인스턴스를 허용합니다. 이전에는 OpenSSL key 또는 OpenSSL X.509 CSR 유형의 리소스가 허용되었습니다.
8.0.0 cipher_algo는 더 이상 선택적 매개변수가 아닙니다.

Examples

예제 #1 openssl_open() 예제

                  
<?php
// $sealed and $env_key are assumed to contain the sealed data
// and our envelope key, both given to us by the sealer.

// fetch private key from file and ready it
$fp = fopen("/src/openssl-0.9.6/demos/sign/key.pem", "r");
$priv_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_privatekey($priv_key);

// decrypt the data and store it in $open
if (openssl_open($sealed, $open, $env_key, $pkeyid)) {
    echo "here is the opened data: ", $open;
} else {
    echo "failed to open data";
}

// free the private key from memory
openssl_free_key($pkeyid);
?>
                  
                

기타