~ubuntu-branches/ubuntu/saucy/trousers/saucy

« back to all changes in this revision

Viewing changes to src/tspi/daa/big_integer/test/multi_exp.c

  • Committer: Package Import Robot
  • Author(s): Pierre Chifflier
  • Date: 2012-06-18 22:22:21 UTC
  • mfrom: (0.1.22 sid)
  • Revision ID: package-import@ubuntu.com-20120618222221-kumdab5nrfx4kvyh
Tags: 0.3.9-1
* Imported Upstream version 0.3.9
* Refreshed Debian patches
* Removed patch 04-gcc46.patch, not required anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
 
 
3
#include <bi.h>
 
4
 
 
5
// use standard C definition to avoid .h
 
6
int test_exp_multi(void) {
 
7
        bi_t result;
 
8
        bi_t g[3];
 
9
        unsigned long e[3];
 
10
 
 
11
        bi_new( result);
 
12
        bi_new( g[0]);
 
13
        bi_new( g[1]);
 
14
        bi_new( g[2]);
 
15
        // result = (2^2 * 5^4 * 7^7) mod 56 -> should give 28
 
16
        bi_set_as_dec( g[0], "2");
 
17
        bi_set_as_dec( g[1], "5");
 
18
        bi_set_as_dec( g[2], "7");
 
19
        e[0] = 2L;
 
20
        e[1] = 4L;
 
21
        e[2] = 7L;
 
22
        bi_multi_mod_exp( result, 3, g, e, 56);
 
23
        printf("multi-exponentiation <result>=%s\n", bi_2_dec_char(result));
 
24
        bi_free( g[0]);
 
25
        bi_free( g[1]);
 
26
        bi_free( g[2]);
 
27
        bi_free( result);
 
28
        return 0;
 
29
}