Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Add PKCS#11 spec refs, placeholder files
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale committed Oct 1, 2014
1 parent dea4883 commit 5d1a882
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 5 deletions.
12 changes: 11 additions & 1 deletion cipher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//
// PKCS#11 s11.8: Encryption functions (on symmetric keys)
// C_EncryptInit
// C_Encrypt
// C_EncryptUpdate
// C_EncryptFinal
// PKCS#11 s11.9: Decryption functions (on symmetric keys)
// C_DecryptInit
// C_Decrypt
// C_DecryptUpdate
// C_DecryptFinal
#include <cstdlib>
#include "pkcs11test.h"

Expand Down
8 changes: 7 additions & 1 deletion digest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//
// PKCS#11 s11.10: Message digesting functions
// C_DigestInit
// C_Digest
// C_DigestUpdate
// C_DigestKey
// C_DigestFinal
#include <string>
#include <cstdlib>
#include "pkcs11test.h"
Expand Down
20 changes: 20 additions & 0 deletions dual.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013-2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// PKCS#11 s11.13: Dual-function cryptographic functions
// C_DigestEncryptUpdate
// C_DecryptDigestUpdate
// C_SignEncryptUpdate
// C_DecryptVerifyUpdate
#include "pkcs11test.h"
11 changes: 11 additions & 0 deletions keypair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// PKCS#11 s11.8: Encryption functions (on asymmetric keys)
// C_EncryptInit
// C_Encrypt
// C_EncryptUpdate
// C_EncryptFinal
// PKCS#11 s11.9: Decryption functions (on asymmetric keys)
// C_DecryptInit
// C_Decrypt
// C_DecryptUpdate
// C_DecryptFinal

#include "pkcs11test.h"

Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dump_chaps: pkcs11test
GTEST_DIR=gtest-1.6.0
GTEST_INC=-isystem $(GTEST_DIR)/include
CXXFLAGS+=-Ithird_party/pkcs11 $(GTEST_INC) -g -std=c++0x -Wall
OBJECTS=pkcs11test.o pkcs11-describe.o globals.o init.o slot.o session.o object.o login.o rng.o tookan.o keypair.o cipher.o digest.o
OBJECTS=pkcs11test.o pkcs11-describe.o globals.o init.o slot.o session.o object.o login.o rng.o tookan.o keypair.o cipher.o digest.o sign.o

pkcs11test: $(OBJECTS) libgtest.a
$(CXX) -g $(GTEST_INCS) -o $@ $(OBJECTS) -ldl libgtest.a -lpthread
Expand Down
4 changes: 4 additions & 0 deletions rng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// PKCS#11 s11.15: Random number generation functions
// C_SeedRandom
// C_GenerateRandom

#include <cstdlib>
#include "pkcs11test.h"
Expand Down
7 changes: 5 additions & 2 deletions session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
// C_GetSessionInfo
// C_GetOperationState
// C_SetOperationState
// PKCS#11 s11.16: Parallel function management functions
// C_GetFunctionStatus
// C_CancelFunction

#include <cstdlib>
#include "pkcs11test.h"
Expand Down Expand Up @@ -138,15 +141,15 @@ TEST_F(ReadWriteSessionTest, InvalidSessionInfo) {
}

TEST_F(ReadOnlySessionTest, CloseSessionInvalid) {
// PKCS#11 11.16: Legacy function which should simply return the value CKR_FUNCTION_NOT_PARALLEL.
// PKCS#11 s11.16: Legacy function which should simply return the value CKR_FUNCTION_NOT_PARALLEL.
EXPECT_CKR(CKR_FUNCTION_NOT_PARALLEL, g_fns->C_GetFunctionStatus(session_));
EXPECT_CKR(CKR_FUNCTION_NOT_PARALLEL, g_fns->C_CancelFunction(session_));

EXPECT_EQ(CKR_SESSION_HANDLE_INVALID, g_fns->C_CloseSession(INVALID_SESSION_HANDLE));
}

TEST_F(ReadWriteSessionTest, CloseSessionInvalid) {
// PKCS#11 11.16: Legacy function which should simply return the value CKR_FUNCTION_NOT_PARALLEL.
// PKCS#11 s11.16: Legacy function which should simply return the value CKR_FUNCTION_NOT_PARALLEL.
EXPECT_CKR(CKR_FUNCTION_NOT_PARALLEL, g_fns->C_GetFunctionStatus(session_));
EXPECT_CKR(CKR_FUNCTION_NOT_PARALLEL, g_fns->C_CancelFunction(session_));

Expand Down
29 changes: 29 additions & 0 deletions sign.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2013-2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// PKCS#11 s11.11: Signing and MACing functions
// C_SignInit
// C_Sign
// C_SignUpdate
// C_SignFinal
// C_SignRecoverInit
// C_SignRecover
// PKCS#11 s11.12: Functions for verifying signatures and MACs
// C_VerifyInit
// C_Verify
// C_VerifyUpdate
// C_VerifyFinal
// C_VerifyRecoverInit
// C_VerifyRecover
#include "pkcs11test.h"

0 comments on commit 5d1a882

Please sign in to comment.