dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / pkcs11 / pkcs11_softtoken / common / softDualCrypt.c
blob56d4674c4dcf292f8ba33a9451c3a009f49b0f48
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <security/cryptoki.h>
30 #include "softGlobal.h"
31 #include "softSession.h"
32 #include "softObject.h"
33 #include "softOps.h"
35 CK_RV
36 C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
37 CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart,
38 CK_ULONG_PTR pulEncryptedPartLen)
41 CK_RV rv;
44 * All the front-end checkings will be done in the
45 * C_EncryptUpdate and C_DigestUpdate.
47 rv = C_EncryptUpdate(hSession, pPart, ulPartLen,
48 pEncryptedPart, pulEncryptedPartLen);
50 if (rv != CKR_OK)
51 return (rv);
54 * If the application just wants to know the length of output
55 * buffer, then we do not digest the data.
57 if (pEncryptedPart == NULL)
58 return (CKR_OK);
60 return (C_DigestUpdate(hSession, pPart, ulPartLen));
64 CK_RV
65 C_DecryptDigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart,
66 CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
69 CK_RV rv;
72 * All the front-end checkings will be done in the
73 * C_DecryptUpdate and C_DigestUpdate.
75 rv = C_DecryptUpdate(hSession, pEncryptedPart, ulEncryptedPartLen,
76 pPart, pulPartLen);
78 if (rv != CKR_OK)
79 return (rv);
82 * If the application just wants to know the length of output
83 * buffer, then we do not digest the data.
85 if (pPart == NULL)
86 return (CKR_OK);
88 return (C_DigestUpdate(hSession, pPart, *pulPartLen));
92 CK_RV
93 C_SignEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
94 CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart,
95 CK_ULONG_PTR pulEncryptedPartLen)
98 CK_RV rv;
101 * All the front-end checkings will be done in the
102 * C_EncryptUpdate and C_SignUpdate.
104 rv = C_EncryptUpdate(hSession, pPart, ulPartLen,
105 pEncryptedPart, pulEncryptedPartLen);
107 if (rv != CKR_OK)
108 return (rv);
111 * If the application just wants to know the length of output
112 * buffer, then we do not sign the data.
114 if (pEncryptedPart == NULL)
115 return (CKR_OK);
117 return (C_SignUpdate(hSession, pPart, ulPartLen));
121 CK_RV
122 C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart,
123 CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
126 CK_RV rv;
129 * All the front-end checkings will be done in the
130 * C_DecryptUpdate and C_VerifyUpdate.
132 rv = C_DecryptUpdate(hSession, pEncryptedPart, ulEncryptedPartLen,
133 pPart, pulPartLen);
135 if (rv != CKR_OK)
136 return (rv);
139 * If the application just wants to know the length of output
140 * buffer, then we do not verify the data.
142 if (pPart == NULL)
143 return (CKR_OK);
145 return (C_VerifyUpdate(hSession, pPart, *pulPartLen));