blob: ca571c67800c5d4300b8ca99abb1ecfcb825fcb8 [file] [log] [blame]
Alexander Afanasyev11225012013-11-21 23:11:10 -08001KeyChain Class
2==============
3
4:[C++]:
5 Namespace: `ndn`
6
7The Keychain class provides a set of interfaces to the security library such as identity management, policy configuration and packet signing and verification.
8
9KeyChain.sign Method
10--------------------
11
12Wire encode the Data object, sign it and set its signature. Note: the caller must make sure the timestamp is correct, if necessary calling ``data.getMetaInfo().setTimestampMilliseconds``.
13
14:[C++]:
15
16 .. code-block:: c++
17
18 void sign(
19
20 Data& data,
21 const Name& certificateName
Alexander Afanasyev11225012013-11-21 23:11:10 -080022
23 );
24
25:Parameters:
26
27 - `data`
28 The Data object to be signed. This updates its signature and key locator field and wireEncoding.
29
30 - `certificateName`
31 The certificate name of the key to use for signing.
32
Alexander Afanasyev11225012013-11-21 23:11:10 -080033KeyChain.signByIdentity Method
34------------------------------
35
36Wire encode the Data object, sign it and set its signature. Note: the caller must make sure the timestamp is correct, if necessary calling ``data.getMetaInfo().setTimestampMilliseconds``.
37
38:[C++]:
39
40 .. code-block:: c++
41
42 void signByIdentity(
43
44 Data& data
45 [, const Name& identityName]
Alexander Afanasyev11225012013-11-21 23:11:10 -080046
47 );
48
49:Parameters:
50
51 - `data`
52 The Data object to be signed. This updates its signature and key locator field and wireEncoding.
53
54 - `identityName`
55 (optional) The identity name for the key to use for signing. If omitted, infer the signing identity from the data packet name.
56
Alexander Afanasyev11225012013-11-21 23:11:10 -080057KeyChain.verifyData Method
58--------------------------
59
60Check the signature on the Data object and call either ``onVerify`` or ``onVerifyFailed``. We use callback functions because verify may fetch information to check the signature.
61
62:[C++]:
63
64 void verifyData(
65
66 const ptr_lib::shared_ptr<Data>& data,
67 const OnVerified& onVerified,
68 const OnVerifyFailed& onVerifyFailed
69
70 );
71
72:Parameters:
73
74 - `data`
75 The Data object with the signature to check. It is an error if data does not have a wireEncoding. To set the wireEncoding, you can call data.wireDecode.
76
77 - `onVerified`
78 If the signature is verified, this calls ``onVerified(data)`` where:
79 - `data` is the given Data object.
80
81 - `onVerifyFailed`
82 If the signature check fails, this calls ``onVerifyFailed(data)`` where:
83 - `data` is the given Data object.
84
85KeyChain.setFace Method
86-----------------------
87
88Set the Face which will be used to fetch required certificates.
89
90:[C++]:
91
92 .. code-block:: c++
93
94 void setFace(
95
96 Face* face
97
98 );
99
100:Parameters:
101
102 - `face`
103 The Face object.