Skip to content

Commit

Permalink
fix email token encryption/decryption hubzero-mailgateway compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
nkissebe committed Aug 7, 2024
1 parent 1ade1c5 commit f66344c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/libraries/Hubzero/Mail/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ public function buildEmailToken($version, $action, $userid, $id)
$binaryString .= str_repeat(chr($pad), $pad);

// Do the encryption
$encrypted = openssl_encrypt($binaryString, 'AES-256-CBC', $this->_key, OPENSSL_RAW_DATA , $this->_iv);
$encrypted = openssl_encrypt($binaryString, 'AES-128-CBC', $this->_key, OPENSSL_RAW_DATA , $this->_iv);

// Prepend an unencrypted version byte and action byte (in base16)
$rv = bin2hex(pack("C", $version)) . bin2hex(pack("C", $action)) . bin2hex($encrypted);
$rv = substr(bin2hex(pack("C", $version)) . bin2hex(pack("C", $action)) . bin2hex($encrypted),0,36);

return $rv;
}
Expand All @@ -165,7 +165,7 @@ public function decryptEmailToken($t)
$encrypted = hex2bin($rawtoken);

// Do the decryption
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $this->_key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $this->_iv);
$decrypted = openssl_decrypt($encrypted, 'AES-128-CBC', $this->_key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $this->_iv);

// unpack the original values, no need to strip padding or hash
// we'll just unpack what we need
Expand Down

0 comments on commit f66344c

Please sign in to comment.