You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.7 KiB
Plaintext
53 lines
2.7 KiB
Plaintext
<?php
|
|
|
|
function fulcrm_crypto_permission() {
|
|
return array( 'administer fulcrm crypto' => array( 'title' => t('Administer fulcrm cryptography'),
|
|
'description' => t('Perform main installation/administration tasks for fulcrm cryptography.'),
|
|
),
|
|
);
|
|
}
|
|
|
|
function fulcrm_crypto_menu() {
|
|
/*
|
|
$items[ 'admin/config/services/fulcrm' ] = array( 'page callback' => 'system_admin_menu_block_page',
|
|
'file' => 'system.admin.inc',
|
|
'file path' => drupal_get_path('module', 'system'),
|
|
'title' => 'fulcrm',
|
|
'description' => 'Configuration integration with fulcrm.org.',
|
|
'position' => 'right',
|
|
'access callback' => 'user_access',
|
|
'access arguments' => array('access administration pages'),
|
|
);
|
|
*/
|
|
$items[ 'admin/config/services/fulcrm/crypto' ] = array( 'page callback' => 'fulcrm_crypto_admin',
|
|
'file' => 'fulcrm_crypto.admin.inc',
|
|
'title' => 'fulcrm cryptography',
|
|
'description' => 'Settings for fulcrm.org cryptography.',
|
|
'access callback' => 'user_access',
|
|
'access arguments' => array('administer fulcrm crypto'),
|
|
);
|
|
|
|
return $items;
|
|
}
|
|
|
|
function fulcrm_crypto_object_id_hmac( $object_type, $object_id ) {
|
|
return drupal_hmac_base64( 'fulcrm:' . strval( $object_id ) . ':' . $object_type, session_id() . drupal_get_hash_salt() );
|
|
}
|
|
|
|
function fulcrm_crypto_object_id_form_value( $object_type, $object_id ) {
|
|
return $object_id . ':' . fulcrm_crypto_object_id_hmac( $object_type, $object_id );
|
|
}
|
|
|
|
function fulcrm_crypto_get_object_id_form_value( $object_type, $form_value ) {
|
|
$bits = explode( ':', $form_value );
|
|
if ( count( $bits ) == 2 ) {
|
|
$object_id = $bits[ 0 ];
|
|
$hmac = $bits[ 1 ];
|
|
$real_hmac = fulcrm_crypto_object_id_hmac( $object_type, $object_id );
|
|
|
|
if ( hash_equals( $real_hmac, $hmac ) )
|
|
return $object_id;
|
|
}
|
|
return NULL;
|
|
}
|