Repository navigation
Expand file tree
/
Copy pathclass-wp-secrets-keyring.php
More file actions
68 lines (64 loc) · 2.03 KB
/
Copy pathclass-wp-secrets-keyring.php
File metadata and controls
68 lines (64 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Secrets API: WP_Secrets_Keyring class
*
* @package WordPress
* @subpackage Secrets
* @since 7.2.0
*/
/**
* Wraps and unwraps the root key that everything else in this API derives from.
*
* A KMS or HSM lives behind this class in a production deployment. An
* implementation is never handed a plaintext secret, only 32 bytes of key material,
* and cannot turn encryption off. There is no method here that
* accepts a plaintext secret value at all.
*
* An implementation should run WP_Secrets_Keyring_Conformance against itself before
* shipping.
*
* Implementations extend this class. It is abstract rather than an interface so
* that a later release can add a method with a default implementation, and every
* existing subclass keeps working.
*
* @since 7.2.0
*/
abstract class WP_Secrets_Keyring {
/**
* Wraps (encrypts) raw key material for storage.
*
* Must not be deterministic: two calls with the same key material must return
* different values. WP_Secrets_Key_Manager::rotate_site_key() stores the
* re-wrapped value with update_site_option(), which reports an unchanged value
* as a failure, and WP_Secrets_Keyring_Conformance checks this.
*
* Attributes are not inherited, so an implementation must mark $key_material
* with #[\SensitiveParameter] itself to keep it out of stack traces.
*
* @since 7.2.0
*
* @param string $key_material Raw key material to protect.
* @return string|WP_Error Opaque wrapped value on success, WP_Error on failure.
*/
abstract public function wrap(
#[\SensitiveParameter]
string $key_material
);
/**
* Unwraps (decrypts) previously wrapped key material.
*
* @since 7.2.0
*
* @param string $wrapped An opaque value previously returned by wrap().
* @return string|WP_Error Raw key material on success, WP_Error on failure.
*/
abstract public function unwrap( string $wrapped );
/**
* A human-readable description of the key source, for Site Health.
*
* @since 7.2.0
*
* @return string
*/
abstract public function get_key_source(): string;
}