1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2 /* All Rights Reserved */
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
10 /* Portions Copyright(c) 1988, Sun Microsystems Inc. */
11 /* All Rights Reserved */
14 * Copyright (c) 1997, by Sun Microsystems, Inc.
15 * All rights reserved.
18 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
21 #include <sys/types.h>
29 mp_pow(MINT
*a
, MINT
*b
, MINT
*c
, MINT
*d
)
35 a0
.len
= b0
.len
= c0
.len
= x
.len
= y
.len
= 0;
41 d
->val
= _mp_xalloc(1, "mp_pow");
43 for (j
= 0; j
< b0
.len
; j
++) {
44 n
= b0
.val
[b0
.len
- j
- 1];
45 for (i
= 0; i
< 15; i
++) {
47 mp_mdiv(&x
, &c0
, &y
, d
);
48 if ((n
= n
<< 1) & 0100000) {
50 mp_mdiv(&x
, &c0
, &y
, d
);
62 mp_rpow(MINT
*a
, short n
, MINT
*b
)
68 x
.val
= _mp_xalloc(1, "mp_rpow");
70 y
.len
= n
* a
->len
+ 4;
71 y
.val
= _mp_xalloc(y
.len
, "mp_rpow2");
72 for (i
= 0; i
< y
.len
; i
++)
74 y
.val
[y
.len
- 1] = 010000;