11/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22/*
3- * Copyright (c) 2013-2023 Regents of the University of California.
3+ * Copyright (c) 2013-2024 Regents of the University of California.
44 *
55 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
66 *
@@ -38,11 +38,9 @@ namespace ndn::security::tpm {
3838namespace cfstring = ndn::detail::cfstring;
3939using ndn::detail::CFReleaser;
4040
41- class BackEndOsx ::Impl
41+ struct BackEndOsx ::Impl
4242{
43- public:
4443 SecKeychainRef keyChainRef;
45- bool isTerminalMode = false ;
4644};
4745
4846static CFReleaser<CFDataRef>
@@ -187,8 +185,6 @@ exportItem(const KeyRefOsx& keyRef, transform::PrivateKey& outKey)
187185BackEndOsx::BackEndOsx (const std::string&)
188186 : m_impl(make_unique<Impl>())
189187{
190- SecKeychainSetUserInteractionAllowed (!m_impl->isTerminalMode );
191-
192188 OSStatus res = SecKeychainCopyDefault (&m_impl->keyChainRef );
193189 if (res == errSecNoDefaultKeychain) {
194190 NDN_THROW (Error (" No default keychain, create one first" ));
@@ -204,49 +200,6 @@ BackEndOsx::getScheme()
204200 return scheme;
205201}
206202
207- bool
208- BackEndOsx::isTerminalMode () const
209- {
210- return m_impl->isTerminalMode ;
211- }
212-
213- void
214- BackEndOsx::setTerminalMode (bool isTerminal) const
215- {
216- m_impl->isTerminalMode = isTerminal;
217- SecKeychainSetUserInteractionAllowed (!isTerminal);
218- }
219-
220- bool
221- BackEndOsx::isTpmLocked () const
222- {
223- SecKeychainStatus keychainStatus;
224- OSStatus res = SecKeychainGetStatus (m_impl->keyChainRef , &keychainStatus);
225- if (res != errSecSuccess)
226- return true ;
227- else
228- return (kSecUnlockStateStatus & keychainStatus) == 0 ;
229- }
230-
231- bool
232- BackEndOsx::unlockTpm (const char * pw, size_t pwLen) const
233- {
234- // If the default key chain is already unlocked, return immediately.
235- if (!isTpmLocked ())
236- return true ;
237-
238- if (m_impl->isTerminalMode ) {
239- // Use the supplied password.
240- SecKeychainUnlock (m_impl->keyChainRef , pwLen, pw, true );
241- }
242- else {
243- // If inTerminal is not set, get the password from GUI.
244- SecKeychainUnlock (m_impl->keyChainRef , 0 , nullptr , false );
245- }
246-
247- return !isTpmLocked ();
248- }
249-
250203ConstBufferPtr
251204BackEndOsx::sign (const KeyRefOsx& key, DigestAlgorithm digestAlgo, const InputBuffers& bufs)
252205{
0 commit comments