Path: blob/main/crypto/krb5/src/tests/misc/test_nfold.c
34907 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright (C) 1998 by the FundsXpress, INC.3*4* All rights reserved.5*6* Export of this software from the United States of America may require7* a specific license from the United States Government. It is the8* responsibility of any person or organization contemplating export to9* obtain such a license before exporting.10*11* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and12* distribute this software and its documentation for any purpose and13* without fee is hereby granted, provided that the above copyright14* notice appear in all copies and that both that copyright notice and15* this permission notice appear in supporting documentation, and that16* the name of FundsXpress. not be used in advertising or publicity pertaining17* to distribution of the software without specific, written prior18* permission. FundsXpress makes no representations about the suitability of19* this software for any purpose. It is provided "as is" without express20* or implied warranty.21*22* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR23* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED24* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.25*/2627#include <stdio.h>28#include <stdlib.h>29#include <string.h>3031int main(int argc, char *argv[])32{33int inlen, outlen, i;34unsigned char *instr, *outstr;3536if (argc != 3) {37fprintf(stderr, "%s: instr outlen\n", argv[0]);38exit(1);39}4041instr = (unsigned char *) argv[1];42inlen = strlen(instr)*8;43outlen = atoi(argv[2]);44if (outlen%8) {45fprintf(stderr, "outlen must be a multiple of 8\n");46exit(1);47}4849if ((outstr = (unsigned char *) malloc(outlen/8)) == NULL) {50fprintf(stderr, "ENOMEM\n");51exit(1);52}5354krb5int_nfold(inlen,instr,outlen,outstr);5556printf("%d-fold(",outlen);57for (i=0; i<(inlen/8); i++)58printf("%02x",instr[i]);59printf(") = ");60for (i=0; i<(outlen/8); i++)61printf("%02x",outstr[i]);62printf("\n");6364exit(0);65}666768