Alexander Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame] | 1 | KeyChain Class |
| 2 | ============== |
| 3 | |
| 4 | :[C++]: |
| 5 | Namespace: `ndn` |
| 6 | |
| 7 | The Keychain class provides a set of interfaces to the security library such as identity management, policy configuration and packet signing and verification. |
| 8 | |
| 9 | KeyChain.sign Method |
| 10 | -------------------- |
| 11 | |
| 12 | Wire 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 Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame] | 22 | |
| 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 Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame] | 33 | KeyChain.signByIdentity Method |
| 34 | ------------------------------ |
| 35 | |
| 36 | Wire 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 Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame] | 46 | |
| 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 Afanasyev | 1122501 | 2013-11-21 23:11:10 -0800 | [diff] [blame] | 57 | KeyChain.verifyData Method |
| 58 | -------------------------- |
| 59 | |
| 60 | Check 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 | |
| 85 | KeyChain.setFace Method |
| 86 | ----------------------- |
| 87 | |
| 88 | Set 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. |