~ubuntu-branches/ubuntu/raring/heimdal/raring

« back to all changes in this revision

Viewing changes to lib/hcrypto/libtommath/bn_mp_is_square.c

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2011-07-21 17:40:58 UTC
  • mfrom: (1.1.12 upstream) (2.4.10 experimental)
  • Revision ID: james.westby@ubuntu.com-20110721174058-byiuowgocek307cs
Tags: 1.5~pre2+git20110720-2
Fix dependency on pthreads when building on Linux 3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
};
39
39
 
40
40
/* Store non-zero to ret if arg is square, and zero if not */
41
 
int mp_is_square(mp_int *arg,int *ret) 
 
41
int mp_is_square(mp_int *arg,int *ret)
42
42
{
43
43
  int           res;
44
44
  mp_digit      c;
46
46
  unsigned long r;
47
47
 
48
48
  /* Default to Non-square :) */
49
 
  *ret = MP_NO; 
 
49
  *ret = MP_NO;
50
50
 
51
51
  if (arg->sign == MP_NEG) {
52
52
    return MP_VAL;
80
80
  r = mp_get_int(&t);
81
81
  /* Check for other prime modules, note it's not an ERROR but we must
82
82
   * free "t" so the easiest way is to goto ERR.  We know that res
83
 
   * is already equal to MP_OKAY from the mp_mod call 
84
 
   */ 
 
83
   * is already equal to MP_OKAY from the mp_mod call
 
84
   */
85
85
  if ( (1L<<(r%11)) & 0x5C4L )             goto ERR;
86
86
  if ( (1L<<(r%13)) & 0x9E4L )             goto ERR;
87
87
  if ( (1L<<(r%17)) & 0x5CE8L )            goto ERR;