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 |
| 22 | [, WireFormat& wireFormat] |
| 23 | |
| 24 | ); |
| 25 | |
| 26 | :Parameters: |
| 27 | |
| 28 | - `data` |
| 29 | The Data object to be signed. This updates its signature and key locator field and wireEncoding. |
| 30 | |
| 31 | - `certificateName` |
| 32 | The certificate name of the key to use for signing. |
| 33 | |
| 34 | - `wireFormat` |
| 35 | (optional) A WireFormat object used to encode the Data object. If omitted, use WireFormat getDefaultWireFormat (). |
| 36 | |
| 37 | KeyChain.signByIdentity Method |
| 38 | ------------------------------ |
| 39 | |
| 40 | 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``. |
| 41 | |
| 42 | :[C++]: |
| 43 | |
| 44 | .. code-block:: c++ |
| 45 | |
| 46 | void signByIdentity( |
| 47 | |
| 48 | Data& data |
| 49 | [, const Name& identityName] |
| 50 | [, WireFormat& wireFormat] |
| 51 | |
| 52 | ); |
| 53 | |
| 54 | :Parameters: |
| 55 | |
| 56 | - `data` |
| 57 | The Data object to be signed. This updates its signature and key locator field and wireEncoding. |
| 58 | |
| 59 | - `identityName` |
| 60 | (optional) The identity name for the key to use for signing. If omitted, infer the signing identity from the data packet name. |
| 61 | |
| 62 | - `wireFormat` |
| 63 | (optional) A WireFormat object used to encode the Data object. If omitted, use WireFormat getDefaultWireFormat (). |
| 64 | |
| 65 | KeyChain.verifyData Method |
| 66 | -------------------------- |
| 67 | |
| 68 | 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. |
| 69 | |
| 70 | :[C++]: |
| 71 | |
| 72 | void verifyData( |
| 73 | |
| 74 | const ptr_lib::shared_ptr<Data>& data, |
| 75 | const OnVerified& onVerified, |
| 76 | const OnVerifyFailed& onVerifyFailed |
| 77 | |
| 78 | ); |
| 79 | |
| 80 | :Parameters: |
| 81 | |
| 82 | - `data` |
| 83 | 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. |
| 84 | |
| 85 | - `onVerified` |
| 86 | If the signature is verified, this calls ``onVerified(data)`` where: |
| 87 | - `data` is the given Data object. |
| 88 | |
| 89 | - `onVerifyFailed` |
| 90 | If the signature check fails, this calls ``onVerifyFailed(data)`` where: |
| 91 | - `data` is the given Data object. |
| 92 | |
| 93 | KeyChain.setFace Method |
| 94 | ----------------------- |
| 95 | |
| 96 | Set the Face which will be used to fetch required certificates. |
| 97 | |
| 98 | :[C++]: |
| 99 | |
| 100 | .. code-block:: c++ |
| 101 | |
| 102 | void setFace( |
| 103 | |
| 104 | Face* face |
| 105 | |
| 106 | ); |
| 107 | |
| 108 | :Parameters: |
| 109 | |
| 110 | - `face` |
| 111 | The Face object. |