1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     ssl_CrlStore.h
4 
5   Copyright (C)2009 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 25843 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_SSL_SSL_CRLSTORE_H_
17 #define NN_SSL_SSL_CRLSTORE_H_
18 
19 #include <nn/util/util_NonCopyable.h>
20 #include <nn/ssl/ssl_Types.h>
21 
22 #ifdef __cplusplus
23 
24 namespace nn {
25 namespace ssl {
26 
27 class Connection;
28 
29 /*!
30   @brief CRLストアを表すクラスです。一つのSSL通信で使用するCRLは、そのすべてのCRLデータをCrlStoreインスタンスに登録後、そのCrlStoreインスタンスをConnectionクラスに設定することになります。
31 */
32 class CrlStore : private nn::util::NonCopyable<CrlStore>
33 {
34     friend class Connection;
35 public:
36     /*!
37       @brief コンストラクタです。
38     */
39     explicit CrlStore();
40 
41     /*!
42       @brief デストラクタです。
43     */
44     virtual ~CrlStore (void);
45 
46     /*!
47       @brief  CRLストアを初期化します。証明書を登録する前に、一度実施する必要があります。
48       @return 処理の結果が返ります。<BR>
49     */
50     nn::Result Initialize(void);
51 
52     /*!
53       @brief  CRLストアの終了処理を行います。CRLストアの全利用が終了したら、一度実施する必要があります。
54       @return 処理の結果が返ります。<BR>
55     */
56     nn::Result Finalize(void);
57 
58     /*!
59       @brief  CRLを登録します。複数回実行することで、複数個のCRLを登録することもできます。
60       @param[in]  pCrlData   CRLデータ。データフォーマットは、X.509 v2のCRLデータ(ASN.1定義)をDERエンコードしたバイナリデータ。
61       @param[in]  crlDatasize pCrlDataのサイズ 。
62       @param[out] pCrlIdCourier 登録したCRLのID.個別に証明書の登録解除(UnRegisterCrl())を実施する際に使用します。不要な場合(個別登録解除が不要の場合。CrlStoreが解放されると、そこに登録されていたCRLは一括で登録解除されますので、その場合は個別登録解除は不要です。)は、未指定とすることができます。
63       @return 処理の結果が返ります。<BR>
64     */
65     nn::Result RegisterCrl(const u8* pCrlData, size_t crlDatasize, CrlId* pCrlIdCourier=NULL);
66 
67     /*!
68       @brief  内蔵CRLを登録します。複数回実行することで、複数個のCRLを登録することもできます。
69       @param[in]  inCrlName 内蔵CRLの名称。
70       @param[out] pCrlIdCourier 登録したCRLのID.個別に証明書の登録解除(UnRegisterCrl())を実施する際に使用します。不要な場合(個別登録解除が不要の場合。CrlStoreが解放されると、そこに登録されていたCRLは一括で登録解除されますので、その場合は個別登録解除は不要です。)は、未指定とすることができます。
71       @return 処理の結果が返ります。<BR>
72     */
73     nn::Result RegisterCrl(InternalCrl inCrlName, CrlId* pCrlIdCourier=NULL);
74 
75     /*!
76       @brief  CRLを登録解除します。
77       @param[in] certId   登録したCRLのID。RegisterCrl()の引数で取得されたものです。
78       @return 処理の結果が返ります。<BR>
79     */
80     nn::Result UnRegisterCrl(CrlId certId);
81 
82 #ifdef NDEBUG_ENABLE
83     /***
84       @brief This is for testing purposes only and is used for obtaining the id of this store.
85       @return The id of this store. <BR>
86      */
GetId()87     CrlStoreId GetId(){return m_crlStoreId;}
88 #endif
89 
90 private:
91     bool m_isInitialized;
92     NN_PADDING3;
93     CrlStoreId m_crlStoreId;
94 
95     /*!
96       @brief  証明書ストアが有効なものか否かを取得します。
97       @return 処理の結果が返ります。<BR>
98     */
IsValid()99     bool IsValid(){return m_isInitialized;}
100 };
101 
102 
103 } // end of namespace ssl
104 } // end of namespace nn
105 
106 #endif // __cplusplus
107 
108 #include <nn/util/detail/util_CLibImpl.h>
109 
110 
111 /*!
112   @addtogroup   nn_ssl               ssl
113   @{
114 
115   @defgroup     nn_ssl_CrlStore_c    CrlStore (C)
116 
117   @brief        @ref nn::ssl::CrlStore の C インタフェースモジュールです。
118 
119   @{
120 */
121 
122 /*!
123   @struct       nnsslCrlStore
124   @brief        SSLのCrlStoreを表す C の構造体です。
125 
126   @brief 対応するクラス @ref nn::ssl::CrlStore を参照してください。
127 */
128 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnsslCrlStore, nn::ssl::CrlStore, 12, u32);
129 
130 /*!
131   @brief 対応する C++ 関数 @ref nn::ssl::CrlStore::Initialize
132 */
133 NN_EXTERN_C nnResult nnsslCrlStoreInitialize(nnsslCrlStore* this_);
134 
135 /*!
136   @brief 対応する C++ 関数 @ref nn::ssl::CrlStore::Finalize
137 */
138 NN_EXTERN_C nnResult nnsslCrlStoreFinalize(nnsslCrlStore* this_);
139 
140 /*!
141   @brief 対応する C++ 関数 @ref nn::ssl::CrlStore::RegisterCrl を参照してください。
142 */
143 NN_EXTERN_C nnResult nnsslCrlStoreRegisterCrl(nnsslCrlStore* this_, const u8* pCrlData, size_t certDatasize, NnSslCrlId* pCrlIdCourier);
144 
145 /*!
146   @brief 対応する C++ 関数 @ref nn::ssl::CrlStore::RegisterCrl を参照してください。
147 */
148 NN_EXTERN_C nnResult nnsslCrlStoreRegistByInternalCrl(nnsslCrlStore* this_, NnSslInternalCrl certId);
149 
150 
151 /*!
152   @brief 対応する C++ 関数 @ref nn::ssl::CrlStore::UnRegisterCrl を参照してください。
153 */
154 NN_EXTERN_C nnResult nnsslCrlStoreUnRegisterCrl(nnsslCrlStore* this_,  NnSslCertId certId);
155 
156 
157 /*!
158   @}
159 
160   @}
161 */
162 
163 #endif /* NN_SSL_SSL_CRLSTORE_H_ */
164