/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Assertion based test of the CBC implementation.
*
* This test can be used to the CBC implementation using either
* 3DES, AES128, AES192 or AES256. The test string above is encrypted
* and then decrypted using one of the algorithms and keys below. The test
* passes if the decrypted string is the same as the original. Note,
* that this test should not be used to test the underlying algorithms
* and relies on the correctness of those algorithms.
*/
#include <stdio.h>
#include <strings.h>
#include "cbc.h"
#include "des3.h"
#include "aes.h"
#include "cbc_test.h"
int
{
void *eh;
int ret;
int i;
switch (type) {
case CBC_DES3_TYPE:
break;
case CBC_AES_128_TYPE:
break;
case CBC_AES_192_TYPE:
break;
case CBC_AES_256_TYPE:
break;
default:
(void) printf("Illegal encryption type\n");
return (-1);
}
if (ret != 0) {
(void) printf("Error initializing encryption algorithm\n");
return (-1);
}
switch (type) {
case CBC_DES3_TYPE:
break;
case CBC_AES_128_TYPE:
break;
case CBC_AES_192_TYPE:
break;
case CBC_AES_256_TYPE:
break;
default:
/* Should not happen */
(void) printf("Illegal encryption type\n");
return (-1);
}
for (i = 0; i < TEST_SIZE; i += TEST_BLOCK_SIZE) {
}
(void) printf("FAILED [Encryption]\n");
goto out;
}
for (i = 0; i < TEST_SIZE; i += TEST_BLOCK_SIZE) {
}
(void) printf("PASSED\n");
} else {
(void) printf("FAILED [Decryption]\n");
}
out:
switch (type) {
case CBC_DES3_TYPE:
break;
case CBC_AES_128_TYPE:
case CBC_AES_192_TYPE:
case CBC_AES_256_TYPE:
break;
default:
/* Should not happen */
(void) printf("Illegal encryption type\n");
return (-1);
}
return (0);
}