Subversion Repositories planix.SVN

Rev

Rev 26 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
26 7u83 1
#include "os.h"
2
#include <mp.h>
3
#include "dat.h"
4
 
5
void
6
mptolel(mpint *b, uchar *p, int n)
7
{
8
	int i, j, m;
9
	mpdigit x;
10
 
11
	memset(p, 0, n);
12
 
13
	m = b->top*Dbytes;
14
	if(m < n)
15
		n = m;
16
 
17
	i = 0;
18
	while(n >= Dbytes){
19
		n -= Dbytes;
20
		x = b->p[i++];
21
		for(j = 0; j < Dbytes; j++){
22
			*p++ = x;
23
			x >>= 8;
24
		}
25
	}
26
	if(n > 0){
27
		x = b->p[i];
28
		for(j = 0; j < n; j++){
29
			*p++ = x;
30
			x >>= 8;
31
		}
32
	}
33
}