decrypt.c revision 30a5e8fa1253cb33980ee4514743cf683f584b4e
088fa5d9eaa83bf4b3d59a64c0519f42a143aaa9Alin Brici * CDDL HEADER START
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * The contents of this file are subject to the terms of the
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * Common Development and Distribution License (the "License").
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * You may not use this file except in compliance with the License.
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * or http://www.opensolaris.org/os/licensing.
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * See the License for the specific language governing permissions
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * and limitations under the License.
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * When distributing Covered Code, include this CDDL HEADER in each
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * If applicable, add the following below this CDDL HEADER, with the
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * fields enclosed by brackets "[]" replaced with your own identifying
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * information: Portions Copyright [yyyy] [name of copyright owner]
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * CDDL HEADER END
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller/* Portions Copyright 2005 Richard Lowe */
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * Use is subject to license terms.
877835274f73615fe922911749e4de093fb26cceBrendan Mmiller#pragma ident "%Z%%M% %I% %E% SMI"
088fa5d9eaa83bf4b3d59a64c0519f42a143aaa9Alin Brici * Implements encrypt(1) and decrypt(1) commands
3f424ffdb194d6ff7ac053c5b3e53211a2de2d64Brendan Mmiller * One binary performs both encrypt/decrypt operation.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <strings.h>
#include <libintl.h>
#include <libgen.h>
#include <locale.h>
#include <limits.h>
#include <cryptoutil.h>
#include <kmfapi.h>
#ifndef EXIT_SUCCESS
struct CommandInfo {
struct mech_alias {
char *alias;
int keysize_unit;
int ivlen;
extern char *optarg;
extern int optind;
char *optstr;
int mech;
static CK_RV
int attrs = 0;
attrs++;
attrs++;
attrs++;
if (keylen > 0) {
attrs++;
return (rv);
goto out;
out:
if (key_obj_count == 0) {
int status;
int mech_match = 0;
if (aflag) {
mech_match++) {
return (EXIT_FAILURE);
if (Kflag) {
&keysize);
} else if (kflag) {
return (EXIT_FAILURE);
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (lflag) {
goto cleanup;
if (Kflag) {
goto cleanup;
i = slotcount;
for (i = 0; i < slotcount; i++) {
if (i == slotcount) {
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (iflag) {
goto cleanup;
goto cleanup;
if (oflag) {
char *dir;
goto cleanup;
goto cleanup;
sizeof (version)) {
goto cleanup;
switch (version) {
goto cleanup;
if (ivlen > 0 &&
goto cleanup;
!= sizeof (salt)) {
goto cleanup;
goto cleanup;
if (Kflag) {
goto cleanup;
goto do_crypto;
if (rv != 0) {
goto cleanup;
int nattr = 0;
nattr++;
nattr++;
nattr++;
nattr++;
nattr++;
keylen = 0;
goto cleanup;
goto cleanup;
!= sizeof (netversion)) {
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
if (inoutsame) {
return (errflag);
while (pos_to_advance > 0) {
switch (status_pos) {
status_pos++;
if (vflag) {
if (!iflag) {
if (status_pos == 0) {
(PROGRESSSIZE)) {
if (pos > 0) {
if (vflag) {
if (iflag)
if (!errflag) {
if (errflag) {
char *filebuf;
int filesize;
int fd;
if (filesize == 0) {
int fd;
if (ivlen == 0) {