@@ -42,7 +42,7 @@ struct CDOC_EXPORT Lock
4242 /* *
4343 * @brief The lock type
4444 */
45- enum Type : unsigned char {
45+ enum Type : unsigned char {
4646 /* *
4747 * @brief Valid capsule but not supported by this library version
4848 *
@@ -51,7 +51,7 @@ struct CDOC_EXPORT Lock
5151 /* *
5252 * @brief Symmetric AES key
5353 */
54- SYMMETRIC_KEY,
54+ SYMMETRIC_KEY,
5555 /* *
5656 * @brief PBKDF key (derived from password)
5757 */
@@ -72,26 +72,26 @@ struct CDOC_EXPORT Lock
7272 * @brief Symmetric key distributed on several servers
7373 */
7474 SHARE_SERVER
75- };
75+ };
7676
7777 /* *
7878 * @brief The public key type
7979 */
80- enum PKType : unsigned char {
80+ enum PKType : unsigned char {
8181 /* *
8282 * Elliptic curve
8383 */
8484 ECC,
8585 /* *
8686 * RSA
8787 */
88- RSA
89- };
88+ RSA
89+ };
9090
9191 /* *
9292 * @brief Extra parameters depending on key type
9393 */
94- enum Params : unsigned int {
94+ enum Params : unsigned int {
9595 /* *
9696 * @brief HKDF salt (SYMMETRIC_KEY, PASSWORD and SHARE_SERVER)
9797 */
@@ -152,7 +152,7 @@ struct CDOC_EXPORT Lock
152152 * @brief CDoc1 specific
153153 */
154154 PARTY_VINFO
155- };
155+ };
156156
157157 /* *
158158 * @brief get lock parameter value
@@ -176,20 +176,20 @@ struct CDOC_EXPORT Lock
176176 /* *
177177 * @brief The lock type
178178 */
179- Type type = Type::UNKNOWN;
179+ Type type = Type::UNKNOWN;
180180 /* *
181181 * @brief algorithm type for public key based locks
182182 */
183- PKType pk_type = PKType::ECC;
183+ PKType pk_type = PKType::ECC;
184184
185185 /* *
186186 * @brief the lock label
187187 */
188- std::string label;
188+ std::string label;
189189 /* *
190190 * @brief encrypted FMK (File Master Key)
191191 */
192- std::vector<uint8_t > encrypted_fmk;
192+ std::vector<uint8_t > encrypted_fmk;
193193
194194 /* *
195195 * @brief check whether lock is valid
@@ -206,11 +206,6 @@ struct CDOC_EXPORT Lock
206206 * @return true if type is CDOC1, PUBLIC_KEY or SERVER
207207 */
208208 constexpr bool isPKI () const noexcept { return (type == Type::CDOC1) || (type == Type::PUBLIC_KEY) || (type == Type::SERVER); }
209- /* *
210- * @brief check whether lock is based on certificate
211- * @return true if type is CDOC1
212- */
213- constexpr bool isCertificate () const noexcept { return (type == Type::CDOC1); }
214209 /* *
215210 * @brief check whether lock is CDoc1 version
216211 * @return true if type is CDOC1
@@ -222,57 +217,32 @@ struct CDOC_EXPORT Lock
222217 */
223218 constexpr bool isRSA () const noexcept { return pk_type == PKType::RSA; }
224219
225- /* *
226- * @brief check whether two locks have the same public key
227- *
228- * This convenience method checks whether both locks are public key based, and if they are,
229- * whether the RCPT_KEY parameters are identical (i.e. both can be decrypted by the same private key)
230- * @param other the other lock
231- * @return true if both have the same public key
232- */
233- bool hasTheSameKey (const Lock &other) const ;
234- /* *
235- * @brief check whether lock has the given public key
236- *
237- * This convenience method checks whether lock is public key based, and if it is,
238- * whether the RCPT_KEY parameters is identical to ptovided key(i.e. it can be decrypted by the corresponding private key)
239- * @param public_key the public key (short format)
240- * @return true if lock has the same public key
241- */
242- bool hasTheSameKey (const std::vector<uint8_t >& public_key) const ;
243-
244- Lock () noexcept = default ;
245- Lock (Type _type) noexcept : type(_type) {};
220+ Lock () noexcept = default ;
221+ Lock (Type _type) noexcept : type(_type) {};
246222
247223 /* *
248224 * @brief Set lock parameter value
249225 * @param param a parameter type
250226 * @param val the value
251227 */
252- void setBytes (Params param, const std::vector<uint8_t >& val) { params[param] = val; }
228+ void setBytes (Params param, std::vector<uint8_t > val) { params[param] = std::move ( val) ; }
253229 /* *
254230 * @brief Set lock parameter value from string
255231 * @param param a parameter type
256232 * @param val the value
257233 */
258- void setString (Params param, const std::string& val) { params[ param] = std::vector< uint8_t >( val.cbegin (), val.cend ()); }
234+ void setString (Params param, const std::string& val) { setBytes ( param, { val.cbegin (), val.cend ()} ); }
259235 /* *
260236 * @brief Set lock parameter value from integer
261237 * @param param a parameter type
262238 * @param val the value
263239 */
264240 void setInt (Params param, int32_t val);
265241
266- /* *
267- * @brief A convenience method to initialize CERTIFICATE, RCPT_KEY and PK_TYPE values from given certificate
268- * @param cert the certificate (der-encoded)
269- */
270- void setCertificate (const std::vector<uint8_t >& cert);
271-
272- bool operator == (const Lock& other) const = default ;
242+ bool operator == (const Lock& other) const noexcept = default ;
273243
274244private:
275- std::map<Params,std::vector<uint8_t >> params;
245+ std::map<Params,std::vector<uint8_t >> params;
276246};
277247
278248} // namespace libcdoc
0 commit comments