CoreFiles by mySites.guru
class-wp-secrets-keyring.php68 lines, 2,083 bytes, from wordpress-7.2-beta5.zip
Raw History Compare with 7.2-beta4
md5
2fc9202fecf234f4d9a1035a14a3b323
sha1
1c081e9ef11d59df846f6034feecb9195a03e286
sha256
136f0a001ca8ff5a0372d92fe5a4007f034f4b8cf5e40a498154fa864e6f2861
<?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;
}

No other release has this exact content. See every version of this file.