Пример #1
0
void srp_user_process_meteor_challenge(SRPUser *usr,
                                       const char *password,
                                       const char *salt,
                                       const char *identity,
                                       const char *Bstr,
                                       const char **Mstr) {
    unsigned char buff[SHA256_DIGEST_LENGTH];
    BN_CTX *ctx = BN_CTX_new();
    
    BIGNUM *u = BN_new();
    BIGNUM *x = BN_new();
    BIGNUM *k = BN_new();
    BIGNUM *kgx = BN_new();
    BIGNUM *aux = BN_new();
    
    meteor_user_generate_u(usr, Bstr, buff, &u);
    meteor_user_generate_x( usr, identity, salt, password, buff, &x );
    meteor_user_generate_k( usr, buff, &k );
    meteor_user_generate_kgx( usr, ctx, x, k, &kgx );
    meteor_user_generate_aux( usr, ctx, u, x, &aux );
    char * S_str;
    meteor_user_generate_S_string(usr, ctx, kgx, aux, Bstr, &S_str);
    *Mstr = meteor_user_generate_M_string(usr, S_str, buff, Bstr);
    meteor_user_generate_HAMK( usr, buff, *Mstr, S_str );
    
    BN_free(u);
    BN_free(x);
    BN_free(k);
    BN_free(kgx);
    BN_free(aux);
}
Пример #2
0
void srp_user_process_meteor_challenge( struct SRPUser * usr,
                                        const char * password,
                                        const char * salt,
                                        const char * identity,
                                        const char * Bstr,
                                        const char ** Mstr )
{
    unsigned char buff[ SHA256_DIGEST_LENGTH ];

    BN_CTX *ctx         = BN_CTX_new();
    BIGNUM *u           = BN_new();
    BIGNUM *x           = BN_new();
    BIGNUM *k           = BN_new();
    BIGNUM *kgx         = BN_new();
    BIGNUM *aux         = BN_new();

    if( !salt || !identity || !Bstr || !Mstr || !ctx )
        goto cleanup_and_exit;

    meteor_user_generate_u(usr, Bstr, buff, &u);

    if( !u )
        goto cleanup_and_exit;

    meteor_user_generate_x( usr, identity, salt, password, buff, &x );

    if( !x )
        goto cleanup_and_exit;

    meteor_user_generate_k( usr, buff, &k );

    if( !k )
        goto cleanup_and_exit;

    meteor_user_generate_kgx( usr, ctx, x, k, &kgx );

    if ( !kgx )
        goto cleanup_and_exit;

    meteor_user_generate_aux( usr, ctx, u, x, &aux );

    if ( !aux )
        goto cleanup_and_exit;

    char * S_str;
    meteor_user_generate_S_string( usr, ctx, kgx, aux, Bstr, &S_str );

    if ( !S_str )
        goto cleanup_and_exit;

    char * M_str;
    meteor_user_generate_M_string( usr, S_str, buff, Bstr, &M_str );
    *Mstr = M_str;

    // calculate and store HAMK for verfication later
    meteor_user_generate_HAMK( usr, buff, M_str, S_str );

  cleanup_and_exit:

    BN_free(u);
    BN_free(x);
    BN_free(k);
    BN_free(kgx);
    BN_CTX_free(ctx);
}