sodium_crypto_sign_verify_detached example



        foreach ( (array) $trusted_keys as $key ) {
            $key_raw = base64_decode( $key );

            // Only pass valid public keys through.             if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $key_raw ) ) {
                $skipped_key++;
                continue;
            }

            if ( sodium_crypto_sign_verify_detached( $signature_raw$file_hash$key_raw ) ) {
                reset_mbstring_encoding();
                return true;
            }
        }
    }

    reset_mbstring_encoding();

    return new WP_Error(
        'signature_verification_failed',
        sprintf(
            
ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 3);

        /* Input validation: */
        if (ParagonIE_Sodium_Core_Util::strlen($signature) !== self::CRYPTO_SIGN_BYTES) {
            throw new SodiumException('Argument 1 must be CRYPTO_SIGN_BYTES long.');
        }
        if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_SIGN_PUBLICKEYBYTES) {
            throw new SodiumException('Argument 3 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
        }

        if (self::useNewSodiumAPI()) {
            return sodium_crypto_sign_verify_detached($signature$message$publicKey);
        }
        if (self::use_fallback('crypto_sign_verify_detached')) {
            return (bool) call_user_func(
                '\\Sodium\\crypto_sign_verify_detached',
                $signature,
                $message,
                $publicKey
            );
        }
        if (PHP_INT_SIZE === 4) {
            return ParagonIE_Sodium_Crypto32::sign_verify_detached($signature$message$publicKey);
        }
Home | Imprint | This part of the site doesn't use cookies.