sec_random_token (public)

 sec_random_token

Defined in packages/acs-tcl/tcl/security-procs.tcl

Generates a random token.

Partial Call Graph (max 5 caller/called nodes):
%3 acs_user::promote_person_to_user acs_user::promote_person_to_user (public) sec_random_token sec_random_token acs_user::promote_person_to_user->sec_random_token ad_change_password ad_change_password (public) ad_change_password->sec_random_token ad_generate_random_string ad_generate_random_string (public) ad_generate_random_string->sec_random_token auth::create_local_account_helper auth::create_local_account_helper (private) auth::create_local_account_helper->sec_random_token sec_populate_secret_tokens_db sec_populate_secret_tokens_db (private) sec_populate_secret_tokens_db->sec_random_token acs::icanuse acs::icanuse (public) sec_random_token->acs::icanuse ad_conn ad_conn (public) sec_random_token->ad_conn

Testcases:
No testcase defined.
Source code:
    # ::tcl_sec_seed is used to maintain a small subset of the previously
    # generated random token to use as the seed for the next
    # token. This makes finding a pattern in sec_random_token harder
    # to guess when it is called multiple times in the same thread.

    if { [ad_conn -connected_p] } {
        set request [ad_conn request]
        set start_clicks [ad_conn start_clicks]
    } else {
        set request "yoursponsoredadvertisementhere"
        set start_clicks "cvs.openacs.org"
    }
    if {[acs::icanuse "ns_crypto::randombytes"]} {
        if {![info exists ::tcl_sec_seed]} { set ::tcl_sec_seed [ns_crypto::randombytes 16].$start_clicks }
        set random_base [ns_sha1 "[ns_time][ns_crypto::randombytes -encoding binary 16]$start_clicks$request$::tcl_sec_seed"]
    } else {
        if {![info exists ::tcl_sec_seed]} { set ::tcl_sec_seed [ns_rand].$start_clicks }
        set random_base [ns_sha1 "[ns_time][ns_rand]$start_clicks$request$::tcl_sec_seed"]
    }
    set ::tcl_sec_seed [string range $random_base 0 10]

    return [ns_sha1 [string range $random_base 11 39]]
Generic XQL file:
packages/acs-tcl/tcl/security-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/security-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/security-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: