1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include <security/cryptoki.h> 28 #include "softGlobal.h" 29 #include "softSession.h" 30 #include "softObject.h" 31 #include "softOps.h" 32 33 CK_RV 34 C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, 35 CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart, 36 CK_ULONG_PTR pulEncryptedPartLen) 37 { 38 39 CK_RV rv; 40 41 /* 42 * All the front-end checkings will be done in the 43 * C_EncryptUpdate and C_DigestUpdate. 44 */ 45 rv = C_EncryptUpdate(hSession, pPart, ulPartLen, 46 pEncryptedPart, pulEncryptedPartLen); 47 48 if (rv != CKR_OK) 49 return (rv); 50 51 /* 52 * If the application just wants to know the length of output 53 * buffer, then we do not digest the data. 54 */ 55 if (pEncryptedPart == NULL) 56 return (CKR_OK); 57 58 return (C_DigestUpdate(hSession, pPart, ulPartLen)); 59 } 60 61 62 CK_RV 63 C_DecryptDigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart, 64 CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen) 65 { 66 67 CK_RV rv; 68 69 /* 70 * All the front-end checkings will be done in the 71 * C_DecryptUpdate and C_DigestUpdate. 72 */ 73 rv = C_DecryptUpdate(hSession, pEncryptedPart, ulEncryptedPartLen, 74 pPart, pulPartLen); 75 76 if (rv != CKR_OK) 77 return (rv); 78 79 /* 80 * If the application just wants to know the length of output 81 * buffer, then we do not digest the data. 82 */ 83 if (pPart == NULL) 84 return (CKR_OK); 85 86 return (C_DigestUpdate(hSession, pPart, *pulPartLen)); 87 } 88 89 90 CK_RV 91 C_SignEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, 92 CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart, 93 CK_ULONG_PTR pulEncryptedPartLen) 94 { 95 96 CK_RV rv; 97 98 /* 99 * All the front-end checkings will be done in the 100 * C_EncryptUpdate and C_SignUpdate. 101 */ 102 rv = C_EncryptUpdate(hSession, pPart, ulPartLen, 103 pEncryptedPart, pulEncryptedPartLen); 104 105 if (rv != CKR_OK) 106 return (rv); 107 108 /* 109 * If the application just wants to know the length of output 110 * buffer, then we do not sign the data. 111 */ 112 if (pEncryptedPart == NULL) 113 return (CKR_OK); 114 115 return (C_SignUpdate(hSession, pPart, ulPartLen)); 116 } 117 118 119 CK_RV 120 C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart, 121 CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen) 122 { 123 124 CK_RV rv; 125 126 /* 127 * All the front-end checkings will be done in the 128 * C_DecryptUpdate and C_VerifyUpdate. 129 */ 130 rv = C_DecryptUpdate(hSession, pEncryptedPart, ulEncryptedPartLen, 131 pPart, pulPartLen); 132 133 if (rv != CKR_OK) 134 return (rv); 135 136 /* 137 * If the application just wants to know the length of output 138 * buffer, then we do not verify the data. 139 */ 140 if (pPart == NULL) 141 return (CKR_OK); 142 143 return (C_VerifyUpdate(hSession, pPart, *pulPartLen)); 144 } 145