Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Cipher Encryption Type #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions wp-multisite-sso.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: WP Multisite SSO
Version: 1.1.1
Version: 1.1.2
Plugin URI: http://voceconnect.com/
Description: Single sign on for a multisite network. Users are authenticated across all sites within the network.
Author: Voce Platforms, Sean McCafferty
Expand Down Expand Up @@ -144,8 +144,20 @@ public static function handle_login( $username, $user ) {
}

// encrypt the sso object
$cipher = 'AES-128-ECB';
$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( $cipher ) );
//$cipher = 'AES-128-CBC';
//$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( $cipher ) );

/* March 2023 Rewrite for PHP 8 Compatibility */

$cipher = 'AES-128-CBC';
$iv_length = openssl_cipher_iv_length($cipher);

if ($iv_length > 0) {
$iv = openssl_random_pseudo_bytes($iv_length);
} else {
// ECB mode or any other mode that does not require an IV
$iv = null;
}

$sso_objects = array_map( function( $sso_object ) use ( $iv, $cipher ) {
// encode the sso object
Expand Down Expand Up @@ -191,7 +203,7 @@ private static function authenticate_user_on_blog() {
$sso = base64_decode( esc_attr( $request_sso ) );

// Decrypt the SSO object.
$cipher = 'AES-128-ECB';
$cipher = 'AES-128-CBC';
$ivlen = openssl_cipher_iv_length( $cipher );
$iv = substr( $sso, 0, $ivlen );
$sha2len = 32;
Expand Down