void des_ecb_enc (des_ctx *ctx, void *input, void *output, uint32_t len) { aes_blk t; aes_blk *in = (aes_blk*)input; aes_blk *out = (aes_blk*)output; uint32_t r; while (len > 0) { // clear t blkclr (&t); // copy input to t r=memxor (&t, &t, in, len); // encrypt des_encrypt (ctx, &t, AES_ENCRYPT); // copy to output blkcpy (out, &t); len -= r; in++; out++; } }
kmstartup() { u_long fromssize, tossize; /* * round lowpc and highpc to multiples of the density we're using * so the rest of the scaling (here and in gprof) stays in ints. */ s_lowpc = (char *) ROUNDDOWN((unsigned)s_lowpc, HISTFRACTION*sizeof(HISTCOUNTER)); s_highpc = (char *) ROUNDUP((unsigned)s_highpc, HISTFRACTION*sizeof(HISTCOUNTER)); s_textsize = s_highpc - s_lowpc; printf("Profiling kernel, s_textsize=%d [%x..%x]\n", s_textsize, s_lowpc, s_highpc); ssiz = (s_textsize / HISTFRACTION) + sizeof(struct phdr); sbuf = (u_short *)calloc(ssiz); if (sbuf == 0) { printf("No space for monitor buffer(s)\n"); return; } blkclr((caddr_t)sbuf, ssiz); fromssize = s_textsize / HASHFRACTION; froms = (u_short *)calloc(fromssize); if (froms == 0) { printf("No space for monitor buffer(s)\n"); cfreemem(sbuf, ssiz); sbuf = 0; return; } blkclr((caddr_t)froms, fromssize); tolimit = s_textsize * ARCDENSITY / 100; if (tolimit < MINARCS) { tolimit = MINARCS; } else if (tolimit > 65534) { tolimit = 65534; } tossize = tolimit * sizeof(struct tostruct); tos = (struct tostruct *)calloc(tossize); if (tos == 0) { printf("No space for monitor buffer(s)\n"); cfreemem(sbuf, ssiz); sbuf = 0; cfreemem(froms, fromssize); froms = 0; return; } blkclr((caddr_t)tos, tossize); tos[0].link = 0; ((struct phdr *)sbuf)->lpc = s_lowpc; ((struct phdr *)sbuf)->hpc = s_highpc; ((struct phdr *)sbuf)->ncnt = ssiz; kcount = (u_short *)(((int)sbuf) + sizeof(struct phdr)); #ifdef notdef /* * profiling is what mcount checks to see if * all the data structures are ready!!! */ profiling = 0; /* patch by hand when you're ready */ #endif }