Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/tests/misc/test_nfold.c
34907 views
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/*
3
* Copyright (C) 1998 by the FundsXpress, INC.
4
*
5
* All rights reserved.
6
*
7
* Export of this software from the United States of America may require
8
* a specific license from the United States Government. It is the
9
* responsibility of any person or organization contemplating export to
10
* obtain such a license before exporting.
11
*
12
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13
* distribute this software and its documentation for any purpose and
14
* without fee is hereby granted, provided that the above copyright
15
* notice appear in all copies and that both that copyright notice and
16
* this permission notice appear in supporting documentation, and that
17
* the name of FundsXpress. not be used in advertising or publicity pertaining
18
* to distribution of the software without specific, written prior
19
* permission. FundsXpress makes no representations about the suitability of
20
* this software for any purpose. It is provided "as is" without express
21
* or implied warranty.
22
*
23
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
24
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
25
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26
*/
27
28
#include <stdio.h>
29
#include <stdlib.h>
30
#include <string.h>
31
32
int main(int argc, char *argv[])
33
{
34
int inlen, outlen, i;
35
unsigned char *instr, *outstr;
36
37
if (argc != 3) {
38
fprintf(stderr, "%s: instr outlen\n", argv[0]);
39
exit(1);
40
}
41
42
instr = (unsigned char *) argv[1];
43
inlen = strlen(instr)*8;
44
outlen = atoi(argv[2]);
45
if (outlen%8) {
46
fprintf(stderr, "outlen must be a multiple of 8\n");
47
exit(1);
48
}
49
50
if ((outstr = (unsigned char *) malloc(outlen/8)) == NULL) {
51
fprintf(stderr, "ENOMEM\n");
52
exit(1);
53
}
54
55
krb5int_nfold(inlen,instr,outlen,outstr);
56
57
printf("%d-fold(",outlen);
58
for (i=0; i<(inlen/8); i++)
59
printf("%02x",instr[i]);
60
printf(") = ");
61
for (i=0; i<(outlen/8); i++)
62
printf("%02x",outstr[i]);
63
printf("\n");
64
65
exit(0);
66
}
67
68