File: client.rst

package info (click to toggle)
python-pykmip 0.10.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,504 kB
  • sloc: python: 102,430; makefile: 33; sh: 12
file content (1401 lines) | stat: -rw-r--r-- 60,110 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
Client
======
The PyKMIP client allows developers to connect to a KMIP-compliant key
management server and conduct key management operations.

Configuration
-------------
The client settings can be managed by a configuration file, by default
located at ``/etc/pykmip/pykmip.conf``. An example client configuration
settings block, as found in the configuration file, is shown below:

.. code-block:: console

    [client]
    host=127.0.0.1
    port=5696
    certfile=/path/to/certificate/file
    keyfile=/path/to/certificate/key/file
    ca_certs=/path/to/ca/certificate/file
    cert_reqs=CERT_REQUIRED
    ssl_version=PROTOCOL_SSLv23
    do_handshake_on_connect=True
    suppress_ragged_eofs=True
    username=example_username
    password=example_password

The configuration file can contain multiple settings blocks. Only one,
``[client]``, is shown above. You can swap between different settings
blocks by simply providing the name of the block as the ``config``
parameter (see below).

The different configuration options are defined below:

* ``host``
    A string representing either a hostname in Internet domain notation or an
    IPv4 address.
* ``port``
    An integer representing a port number. Recommended to be ``5696``
    according to the KMIP specification.
* ``certfile``
    A string representing a path to a PEM-encoded client certificate file. For
    more information, see the `ssl`_ documentation.
* ``keyfile``
    A string representing a path to a PEM-encoded client certificate key file.
    The private key contained in the file must correspond to the certificate
    pointed to by ``certfile``. For more information, see the `ssl`_
    documentation.
* ``ca_certs``
    A string representing a path to a PEM-encoded certificate authority
    certificate file. This certificate will be used to verify the server's
    certificate when establishing a TLS connection. For more information, see
    the `ssl`_ documentation.
* ``cert_reqs``
    A flag indicating the enforcement level to use when validating the
    certificate received from the server. Options include: ``CERT_NONE``,
    ``CERT_OPTIONAL``, and ``CERT_REQUIRED``. ``CERT_REQUIRED`` is the most
    secure option and should be used at all times. The other options can be
    helpful when debugging TLS connections. For more information, see the
    `ssl`_ documentation.
* ``ssl_version``
    A flag indicating the SSL/TLS version to use when establishing a TLS
    connection with a server. Options are derived from the `ssl`_ module.
    The recommended value is ``PROTOCOL_SSLv23`` or ``PROTOCOL_TLS``, which
    automatically allows the client to pick the most secure option provided
    by the server. For more information, see the `ssl`_ documentation.
* ``do_handshake_on_connect``
    A boolean flag indicating when the client should perform the TLS handshake
    when establishing the TLS connection. The recommended value is ``True``.
    For more information, see the `ssl`_ documentation.

    .. note::
       This configuration option is deprecated and will be removed in a future
       version of PyKMIP.
* ``suppress_ragged_eofs``
    A boolean flag indicating how the client should handle unexpected EOF from
    the TLS connection. The recommended value is ``True``. For more
    information, see the `ssl`_ documentation.

    .. note::
       This configuration option is deprecated and will be removed in a future
       version of PyKMIP.
* ``username``
    A string representing the username to use for KMIP requests. Optional
    depending on server access policies. Leave blank if not needed.
* ``password``
    A string representing the password to use for KMIP requests. Optional
    depending on server access policies. Leave blank if not needed.

The client can also be configured manually via Python. The following example
shows how to create the ``ProxyKmipClient`` in Python code, directly
specifying the different configuration values:

.. code-block:: python

    >>> import ssl
    >>> from kmip.pie.client import ProxyKmipClient, enums
    >>> client = ProxyKmipClient(
    ...     hostname='127.0.0.1',
    ...     port=5696,
    ...     cert='/path/to/certificate/file',
    ...     key='/path/to/certificate/key/file',
    ...     ca='/path/to/ca/certificate/file',
    ...     ssl_version=ssl.PROTOCOL_SSLv23,
    ...     username='example_username',
    ...     password='example_password',
    ...     config='client',
    ...     config_file='/etc/pykmip/pykmip.conf',
    ...     kmip_version=enums.KMIPVersion.KMIP_1_2
    ... )

Settings specified at runtime, as in the above example, will take precedence
over the default values found in the configuration file.

Usage
-----

The following class documentation provides numerous examples detailing how to
use the client. For additional examples, demo scripts for different operations
are available in the ``kmip/demos/pie`` directory.

Class Documentation
-------------------
.. py:module:: kmip.pie.client

.. py:class:: ProxyKmipClient(hostname=None, port=None, cert=None, key=None, ca=None, ssl_version=None, username=None, password=None, config='client', config_file=None, kmip_version=None)

    A simplified KMIP client for conducting KMIP operations.

    The ProxyKmipClient is a simpler KMIP client supporting various KMIP
    operations. It wraps the original KMIPProxy, reducing the boilerplate
    needed to deploy PyKMIP in client applications. The underlying proxy
    client is responsible for setting up the underlying socket connection
    and for writing/reading data to/from the socket.

    Like the KMIPProxy, the ProxyKmipClient is not thread-safe.

    :param string hostname: The host or IP address of a KMIP appliance.
        Optional, defaults to None.
    :param int port: The port number used to establish a connection to a
        KMIP appliance. Usually 5696 for KMIP applications. Optional,
        defaults to None.
    :param string cert: The path to the client's certificate. Optional,
        defaults to None.
    :param string key: The path to the key for the client's certificate.
        Optional, defaults to None.
    :param string ca: The path to the CA certificate used to verify the
        server's certificate. Optional, defaults to None.
    :param string ssl_version: The name of the ssl version to use for the
        connection. Example: 'PROTOCOL_SSLv23'. Optional, defaults to None.
    :param string username: The username of the KMIP appliance account to
        use for operations. Optional, defaults to None.
    :param string password: The password of the KMIP appliance account to
        use for operations. Optional, defaults to None.
    :param string config: The name of a section in the PyKMIP configuration
        file. Use to load a specific set of configuration settings from the
        configuration file, instead of specifying them manually. Optional,
        defaults to the default client section, 'client'.
    :param string config_file: The path to the PyKMIP client configuration
        file. Optional, defaults to None.
    :param enum kmip_version: A KMIPVersion enumeration specifying which KMIP
        version should be used to encode/decode request/response messages.
        Optional, defaults to None. If no value is specified, at request
        encoding time the client will default to KMIP 1.2.

    .. py:attribute:: kmip_version

        The KMIP version that should be used to encode/decode request/response
        messages. Must be a KMIPVersion enumeration. Can be accessed and
        modified at any time.

    .. py:method:: open()

        Open the client connection.

        :raises kmip.pie.exceptions.ClientConnectionFailure: This is raised if
            the client connection is already open.
        :raises Exception: This is raised if an error occurs while trying to
            open the connection.

    .. py:method:: close()

        Close the client connection.

        :raises Exception: This is raised if an error occurs while trying to
            close the connection.

    .. py:method:: activate(uid=None)

        Activate a managed object stored by a KMIP appliance.

        :param string uid: The unique ID of the managed object to activate.
            Optional, defaults to None.

        :return: None

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Activating a symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.activate(key_id)

    .. py:method:: check(uid=None, usage_limits_count=None, cryptographic_usage_mask=None, lease_time=None)

        Check the constraints for a managed object.

        :param string uid: The unique ID of the managed object to check.
        :param int usage_limits_count: The number of items that can be secured
            with the specified managed object.
        :param list cryptographic_usage_mask: A list of :class:`kmip.core.enums.CryptographicUsageMask`
            enumerations specifying the operations allowed for the specified
            managed object.
        :param int least_time: The number of seconds that can be leased for the
            specified managed object.

        :return: The string ID of the managed object that was checked.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input arguments are invalid.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.check(
            ...         uid="1",
            ...         usage_limits_count=50
            ...     )
            '1'

    .. py:method:: create(algorithm, length, operation_policy_name=None, name=None, cryptographic_usage_mask=None)

        Create a symmetric key on a KMIP appliance.

        :param algorithm: A :class:`kmip.core.enums.CryptographicAlgorithm`
            enumeration defining the algorithm to use to generate the symmetric
            key. See :term:`cryptographic_algorithm` for more information.
        :param int length: The length in bits for the symmetric key.
        :param string operation_policy_name: The name of the operation policy
            to use for the new symmetric key. Optional, defaults to None
        :param string name: The name to give the key. Optional, defaults to
            None.
        :param list cryptographic_usage_mask: A list of
            :class:`kmip.core.enums.CryptographicUsageMask` enumerations
            defining how the created key should be used. Optional, defaults to
            None. See :term:`cryptographic_usage_mask` for more information.

        :return: The string uid of the newly created symmetric key.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input arguments are invalid.

        Creating an 256-bit AES key used for encryption and decryption would
        look like this:

        .. code-block:: python

            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     key_id = c.create(
            ...         enums.CryptographicAlgorithm.AES,
            ...         256,
            ...         operation_policy_name='default',
            ...         name='Test_256_AES_Symmetric_Key',
            ...         cryptographic_usage_mask=[
            ...             enums.CryptographicUsageMask.ENCRYPT,
            ...             enums.CryptographicUsageMask.DECRYPT
            ...         ]
            ...     )
            '449'

    .. py:method:: create_key_pair(algorithm, length, operation_policy_name=None, public_name=None, public_usage_mask=None, private_name=None, private_usage_mask=None)

        Create an asymmetric key pair on a KMIP appliance.

        :param algorithm: A :class:`kmip.core.enums.CryptographicAlgorithm`
            enumeration defining the algorithm to use to generate the key pair.
            See :term:`cryptographic_algorithm` for more information.
        :param int length: The length in bits for the key pair.
        :param string operation_policy_name: The name of the operation policy
            to use for the new key pair. Optional, defaults to None.
        :param string public_name: The name to give the public key. Optional,
            defaults to None.
        :param list public_usage_mask: A list of
            :class:`kmip.core.enums.CryptographicUsageMask` enumerations
            indicating how the public key should be used. Optional, defaults to
            None. See :term:`cryptographic_usage_mask` for more information.
        :param string private_name: The name to give the public key. Optional,
            defaults to None.
        :param list private_usage_mask: A list of
            :class:`kmip.core.enums.CryptographicUsageMask` enumerations
            indicating how the private key should be used. Optional, defaults
            to None. See :term:`cryptographic_usage_mask` for more information.

        :return: The string uid of the newly created public key.
        :return: The string uid of the newly created private key.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure
        :raises TypeError: This is raised if the input arguments are invalid.

        Creating an 2048-bit RSA key pair to be used for signing and signature
        verification would look like this:

        .. code-block:: python

            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     key_id = c.create_key_pair(
            ...         enums.CryptographicAlgorithm.RSA,
            ...         2048,
            ...         operation_policy_name='default',
            ...         public_name='Test_2048_RSA_Public_Key',
            ...         public_usage_mask=[
            ...             enums.CryptographicUsageMask.VERIFY
            ...         ],
            ...         private_name='Test_2048_RSA_Private_Key',
            ...         private_usage_mask=[
            ...             enums.CryptographicUsageMask.SIGN
            ...         ]
            ...     )
            ('450', '451')

    .. py:method:: decrypt(data, uid=None, cryptographic_parameters=None, iv_counter_nonce=None)

        Decrypt data using the specified decryption key and parameters.

        :param bytes data: The bytes to decrypt. Required.
        :param string uid: The unique ID of the decryption key to use.
            Optional, defaults to None.
        :param dict cryptographic_parameters: A dictionary containing various
            cryptographic settings to be used for the decryption. Optional,
            defaults to None. See :term:`cryptographic_parameters` for more
            information.
        :param bytes iv_counter_nonce: The bytes to use for the IV/counter/
            nonce, if needed by the decryption algorithm and/or cipher mode.
            Optional, defaults to None.

        :return: The decrypted data bytes.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Decrypting cipher text with a symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     key_id = c.create(
            ...         enums.CryptographicAlgorithm.AES,
            ...         256,
            ...         cryptographic_usage_mask=[
            ...             enums.CryptographicUsageMask.ENCRYPT,
            ...             enums.CryptographicUsageMask.DECRYPT
            ...         ]
            ...     )
            ...     c.activate(key_id)
            ...     c.decrypt(
            ...         (
            ...             b' \xb6:s0\x16\xea\t\x1b\x16\xed\xb2\x04-\xd6'
            ...             b'\xb6\\\xf3xJ\xfe\xa7[\x1eJ\x08I\xae\x14\xd2'
            ...             b\xdb\xe2'
            ...         ),
            ...         uid=key_id,
            ...         cryptographic_parameters={
            ...             'cryptographic_algorithm':
            ...                 enums.CryptographicAlgorithm.AES,
            ...             'block_cipher_mode': enums.BlockCipherMode.CBC,
            ...             'padding_method': enums.PaddingMethod.PKCS5
            ...         },
            ...         iv_counter_nonce=(
            ...             b'\x85\x1e\x87\x64\x77\x6e\x67\x96'
            ...             b'\xaa\xb7\x22\xdb\xb6\x44\xac\xe8'
            ...         )
            ...     )
            ...
            b'This is a secret message.'

    .. py:method:: delete_attribute(unique_identifier=None, **kwargs)

        Delete an attribute from a managed object.

        :param string unique_identifier: The unique ID of the managed object
            from which to delete the specified attribute.
        :param `**kwargs`: A placeholder for attribute values used to identify
            the attribute to delete. See the examples below for more
            information.

        :return: The string ID of the managed object from which the
            attribute was deleted.
        :return: A :class:`kmip.core.primitives.Struct` object
            representing the deleted attribute. Only returned for KMIP
            1.0 - 1.4 messages.

        For KMIP 1.0 - 1.4, the supported `kwargs` values are:

        * `attribute_name` (string): The name of the attribute to delete. Required.
        * `attribute_index` (int): The index of the attribute to delete. Defaults to zero.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.delete_attribute(
            ...         unique_identifier="1",
            ...         attribute_name="Name",
            ...         attribute_index=0
            ...     )
            ('1', Attribute(...))

        For KMIP 2.0+, the supported `kwargs` values are:

        * `current_attribute` (struct): A :class:`kmip.core.objects.CurrentAttribute` object containing the attribute to delete. Required if the attribute reference is not specified.
        * `attribute_reference` (struct): A :class:`kmip.core.objects.AttributeReference` object containing the name of the attribute to delete. Required if the current attribute is not specified.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> from kmip.core import objects, primitives
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.delete_attribute(
            ...         unique_identifier="1",
            ...         current_attribute=objects.CurrentAttribute(
            ...             attribute=primitives.TextString(
            ...                 value="Object Group 1",
            ...                 tag=enums.Tags.OBJECT_GROUP
            ...             ),
            ...         ),
            ...         attribute_reference=objects.AttributeReference(
            ...             vendor_identification="Vendor 1",
            ...             attribute_name="Object Group"
            ...         )
            ...     )
            '1'

    .. py:method:: derive_key(object_type, unique_identifiers, derivation_method, derivation_parameters, **kwargs)

        Derive a new key or secret data from existing managed objects.

        :param object_type: A :class:`kmip.core.enums.ObjectType` enumeration
            specifying what type of object to derive. Only SymmetricKeys and
            SecretData can be specified. Required. See :term:`object_type` for
            more information.
        :param list unique_identifiers: A list of strings specifying the
            unique IDs of the existing managed objects to use for derivation.
            Multiple objects can be specified to fit the requirements of the
            given derivation method. Required.
        :param derivation_method: A :class:`kmip.core.enums.DerivationMethod`
            enumeration specifying how key derivation should be done. Required.
            See :term:`derivation_method` for more information.
        :param dict `derivation_parameters`: A dictionary containing various
            settings for the key derivation process. Required. See
            :term:`derivation_parameters` for more information.
        :param `**kwargs`: A placeholder for object attributes that should be set
            on the newly derived object. See the examples below for more
            information.

        :return: The unique string ID of the newly derived object.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input arguments are invalid.

        Deriving a new key using PBKDF2 would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> secret_data = objects.SecretData(
            ...     b'password',
            ...     enums.SecretDataType.PASSWORD,
            ...     masks=[
            ...         enums.CryptographicUsageMask.DERIVE_KEY
            ...     ]
            ... )
            >>> with c:
            ...     password_id = c.register(secret_data)
            ...     c.activate(password_id)
            ...     c.derive_key(
            ...         enums.ObjectType.SYMMETRIC_KEY,
            ...         [password_id],
            ...         enums.DerivationMethod.PBKDF2,
            ...         {
            ...             'cryptographic_parameters': {
            ...                 'hashing_algorithm':
            ...                     enums.HashingAlgorithm.SHA_1
            ...             },
            ...             'salt': b'salt',
            ...             'iteration_count': 4096
            ...         },
            ...         cryptographic_length=128,
            ...         cryptographic_algorithm=enums.CryptographicAlgorithm.AES
            ...     )
            ...
            '454'

        Deriving a new secret using encryption would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.BLOWFISH,
            ...     128,
            ...     (
            ...         b'\x01\x23\x45\x67\x89\xAB\xCD\xEF'
            ...         b'\xF0\xE1\xD2\xC3\xB4\xA5\x96\x87'
            ...     ),
            ...     masks=[
            ...         enums.CryptographicUsageMask.DERIVE_KEY
            ...     ]
            ... )
            >>> with c:
            ...     key_id = c.register(key)
            ...     c.activate(key_id)
            ...     c.derive_key(
            ...         enums.ObjectType.SECRET_DATA,
            ...         [key_id],
            ...         enums.DerivationMethod.ENCRYPT,
            ...         {
            ...             'cryptographic_parameters': {
            ...                 'block_cipher_mode': enums.BlockCipherMode.CBC,
            ...                 'padding_method': enums.PaddingMethod.PKCS5,
            ...                 'cryptographic_algorithm':
            ...                     enums.CryptographicAlgorithm.BLOWFISH
            ...             },
            ...             'initialization_vector': (
            ...                 b'\xFE\xDC\xBA\x98\x76\x54\x32\x10'
            ...             ),
            ...             'derivation_data': (
            ...                 b'\x37\x36\x35\x34\x33\x32\x31\x20'
            ...                 b'\x4E\x6F\x77\x20\x69\x73\x20\x74'
            ...                 b'\x68\x65\x20\x74\x69\x6D\x65\x20'
            ...                 b'\x66\x6F\x72\x20\x00'
            ...             )
            ...         },
            ...         cryptographic_length=256
            ...     )
            ...
            '456'

        Deriving a new key using NIST 800 108-C would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     512,
            ...     (
            ...         b'\xdd\x5d\xbd\x45\x59\x3e\xe2\xac'
            ...         b'\x13\x97\x48\xe7\x64\x5b\x45\x0f'
            ...         b'\x22\x3d\x2f\xf2\x97\xb7\x3f\xd7'
            ...         b'\x1c\xbc\xeb\xe7\x1d\x41\x65\x3c'
            ...         b'\x95\x0b\x88\x50\x0d\xe5\x32\x2d'
            ...         b'\x99\xef\x18\xdf\xdd\x30\x42\x82'
            ...         b'\x94\xc4\xb3\x09\x4f\x4c\x95\x43'
            ...         b'\x34\xe5\x93\xbd\x98\x2e\xc6\x14'
            ...     ),
            ...     masks=[
            ...         enums.CryptographicUsageMask.DERIVE_KEY
            ...     ]
            ... )
            >>> with c:
            ...     key_id = c.register(key)
            ...     c.activate(key_id)
            ...     c.derive_key(
            ...         enums.ObjectType.SYMMETRIC_KEY,
            ...         [key_id],
            ...         enums.DerivationMethod.NIST800_108_C,
            ...         {
            ...             'cryptographic_parameters': {
            ...                 'hashing_algorithm':
            ...                     enums.HashingAlgorithm.SHA_512
            ...             },
            ...             'derivation_data': (
            ...                 b'\xb5\x0b\x0c\x96\x3c\x6b\x30\x34'
            ...                 b'\xb8\xcf\x19\xcd\x3f\x5c\x4e\xbe'
            ...                 b'\x4f\x49\x85\xaf\x0c\x03\xe5\x75'
            ...                 b'\xdb\x62\xe6\xfd\xf1\xec\xfe\x4f'
            ...                 b'\x28\xb9\x5d\x7c\xe1\x6d\xf8\x58'
            ...                 b'\x43\x24\x6e\x15\x57\xce\x95\xbb'
            ...                 b'\x26\xcc\x9a\x21\x97\x4b\xbd\x2e'
            ...                 b'\xb6\x9e\x83\x55'
            ...             )
            ...         },
            ...         cryptographic_length=128,
            ...         cryptographic_algorithm=enums.CryptographicAlgorithm.AES
            ...     )
            ...
            '458'

        Deriving a new secret using HMAC would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> secret = objects.SecretData(
            ...     (
            ...         b'\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c'
            ...         b'\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c'
            ...         b'\x0c\x0c\x0c\x0c\x0c\x0c'
            ...     ),
            ...     enums.SecretDataType.SEED,
            ...     masks=[
            ...         enums.CryptographicUsageMask.DERIVE_KEY
            ...     ]
            ... )
            >>> with c:
            ...     secret_id = c.register(secret)
            ...     c.activate(secret_id)
            ...     c.derive_key(
            ...         enums.ObjectType.SECRET_DATA,
            ...         [secret_id],
            ...         enums.DerivationMethod.HMAC,
            ...         {
            ...             'cryptographic_parameters': {
            ...                 'hashing_algorithm':
            ...                     enums.HashingAlgorithm.SHA_1
            ...             },
            ...             'derivation_data': b'',
            ...             'salt': b''
            ...         },
            ...         cryptographic_length=336
            ...     )
            ...
            '460'

    .. py:method:: destroy(uid=None)

        Destroy a managed object stored by a KMIP appliance.

        :param string uid: The unique ID of the managed object to destroy.

        :return: None

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Destroying a symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.destroy(key_id)

    .. py:method:: encrypt(data, uid=None, cryptographic_parameters=None, iv_counter_nonce=None)

        Encrypt data using the specified encryption key and parameters.

        :param bytes data: The bytes to encrypt. Required.
        :param string uid: The unique ID of the encryption key to use.
            Optional, defaults to None.
        :param dict cryptographic_parameters: A dictionary containing various
            cryptographic settings to be used for the encryption. Optional,
            defaults to None. See :term:`cryptographic_parameters` for more
            information.
        :param bytes iv_counter_nonce: The bytes to use for the IV/counter/
            nonce, if needed by the encryption algorithm and/or cipher mode.
            Optional, defaults to None.

        :return: The encrypted data bytes.
        :return: The IV/counter/nonce bytes used with the encryption algorithm,
            only if it was autogenerated by the server.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Encrypting plain text with a symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     key_id = c.create(
            ...         enums.CryptographicAlgorithm.AES,
            ...         256,
            ...         cryptographic_usage_mask=[
            ...             enums.CryptographicUsageMask.ENCRYPT,
            ...             enums.CryptographicUsageMask.DECRYPT
            ...         ]
            ...     )
            ...     c.activate(key_id)
            ...     c.encrypt(
            ...         b'This is a secret message.',
            ...         uid=key_id,
            ...         cryptographic_parameters={
            ...             'cryptographic_algorithm':
            ...                 enums.CryptographicAlgorithm.AES,
            ...             'block_cipher_mode': enums.BlockCipherMode.CBC,
            ...             'padding_method': enums.PaddingMethod.PKCS5
            ...         },
            ...         iv_counter_nonce=(
            ...             b'\x85\x1e\x87\x64\x77\x6e\x67\x96'
            ...             b'\xaa\xb7\x22\xdb\xb6\x44\xac\xe8'
            ...         )
            ...     )
            ...
            (b'...', None)

    .. py:method:: get(uid=None, key_wrapping_specification=None)

        Get a managed object from a KMIP appliance.

        :param string uid: The unique ID of the managed object to retrieve.
        :param dict key_wrapping_specification: A dictionary containing the
            settings to use to wrap the object before retrieval. Optional,
            defaults to None. See :term:`key_wrapping_specification` for
            more information.

        :return: An :class:`kmip.pie.objects.ManagedObject` instance.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Getting a symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.get(key_id)
            SymmetricKey(...)

        Getting a wrapped symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> wrapping_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x11\x22\x33\x44\x55\x66\x77'
            ...         b'\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF'
            ...     ),
            ...     [
            ...         enums.CryptographicUsageMask.WRAP_KEY
            ...     ]
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     wrapping_key_id = c.register(wrapping_key)
            ...     c.activate(wrapping_key_id)
            ...     c.get(
            ...         key_id,
            ...         key_wrapping_specification={
            ...             'wrapping_method': enums.WrappingMethod.ENCRYPT,
            ...             'encryption_key_information': {
            ...                 'unique_identifier': wrapping_key_id,
            ...                 'cryptographic_parameters': {
            ...                     'block_cipher_mode':
            ...                         enums.BlockCipherMode.NIST_KEY_WRAP
            ...                 }
            ...             },
            ...             'encoding_option': enums.EncodingOption.NO_ENCODING
            ...         }
            ...     )
            SymmetricKey(...)

    .. py:method:: get_attributes(uid=None, attribute_names=None)

        Get the attributes associated with a managed object.

        If the uid is not specified, the appliance will use the ID placeholder
        by default.

        If the attribute_names list is not specified, the appliance will
        return all viable attributes for the managed object.

        :param string uid: The unique ID of the managed object with which the
            retrieved attributes should be associated. Optional, defaults to
            None.
        :param list attribute_names: A list of string attribute names
            indicating which attributes should be retrieved. Optional, defaults
            to None.

        :return: The string ID of the object the attributes belong to.
        :return: A list of :class:`kmip.core.objects.Attribute` instances.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Retrieving all of the attributes for a managed object would look like
        this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.get_attributes(key_id)
            ('458', [Attribute(...), Attribute(...), ...])

        Retrieving only a specific attribute for a managed object would look
        like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.get_attributes(key_id, ['Cryptographic Length'])
            ...
            (
                '458',
                [
                    Attribute(
                        attribute_name=AttributeName(value='Cryptographic Length'),
                        attribute_index=None,
                        attribute_value=CryptographicLength(value=128)
                    )
                ]
            )

    .. py:method:: get_attribute_list(uid=None)

        Get the names of the attributes associated with a managed object.

        If the uid is not specified, the appliance will use the ID placeholder
        by default.

        :param string uid: The unique ID of the managed object with which the
            retrieved attribute names should be associated. Optional, defaults
            to None.

        Retrieving the list of attribute names for a symmetric key would look
        like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.get_attribute_list(key_id)
            ...
            [
                'Cryptographic Algorithm',
                'Cryptographic Length',
                'Cryptographic Usage Mask',
                'Initial Date',
                'Object Type',
                'Operation Policy Name',
                'State',
                'Unique Identifier'
            ]

    .. py:method:: locate(maximum_items=None, storage_status_mask=None, object_group_member=None, offset_items=None, attributes=None)

        Search for managed objects with specific matching attributes.

        :param int maximum_items: The maximum number of results that should be
            returned.
        :param int storage_status_mask: A bit-mask indicating whether online or
            archived objects should be included in the search. See
            :term:`storage_status` for more information.
        :param enum object_group_member: A :class:`kmip.core.enums.ObjectGroupMember`
            enumeration indicating the object group member type. See
            :term:`object_group_member` for more information.
        :param int offset_items: The number of results that should be skipped
            before results are returned.
        :param list attributes: A list of :class:`kmip.core.objects.Attribute`
            objects representing an attribute filter for the search.

        :return: A list of string IDs of all matching objects, per the operation parameters.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> from kmip.core import enums
            >>> from kmip.core.factories import attributes
            >>> f = attributes.AttributeFactory()
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.locate(
            ...         attributes=[
            ...             f.create_attribute(
            ...                 enums.AttributeType.OBJECT_TYPE,
            ...                 enums.ObjectType.SYMMETRIC_KEY
            ...             )
            ...         ]
            ...     )
            ['1', '2', '3']

    .. py:method:: mac(data, uid=None, algorithm=None)

        Get the message authentication code for a piece of data.

        :param string data: The data to be MACed.
        :param string uid: The unique ID of the managed object that is the key
            to be used in the MAC operation.
        :param enum algorithm: A :class:`kmip.core.enums.CryptographicAlgorithm`
            enumeration specifying the algorithm to use in the MAC operation.
            See :term:`cryptographic_algorithm` for more information.

        :return: The string ID of the managed object that is the key used in
            the MAC operation.
        :return: The bytestring representing the MAC of the data.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.mac(
            ...         b'\x01\x02\x03\x04',
            ...         uid="5",
            ...         algorithm=enums.CryptographicAlgorithm.HMAC_SHA512
            ...     )
            ('5', b'...')

    .. py:method:: modify_attribute(unique_identifier=None, **kwargs)

        Modify an attribute on a managed object.

        :param string unique_identifier: The unique ID of the managed object
            on which to set the specified attribute.
        :param `**kwargs`: A placeholder for attribute values used to identify
            the attribute to set. See the example below for more
            information.

        :return: The string ID of the managed object on which the attribute
            was set.
        :return: A :class:`kmip.core.primitives.Struct` object representing
            the modified attribute. Only returned for KMIP 1.0 - 1.4 messages.

        For KMIP 1.0 - 1.4, the supported `kwargs` values are:

        * `attribute` (struct): A :class:`kmip.core.objects.Attribute` object
            containing the details required to identify and modify an existing
            attribute on the specified managed object. Required.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> from kmip.core import enums
            >>> from kmip.core.factories import attributes
            >>> f = attributes.AttributeFactory()
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.modify_attribute(
            ...         unique_identifier="1",
            ...         attribute=f.create_attribute(
            ...             enums.AttributeType.NAME,
            ...             "New Name",
            ...             index=0
            ...         )
            ...     )
            ('1', Attribute(...))

        For KMIP 2.0+, the supported `kwargs` values are:

        * `current_attribute` (struct): A :class:`kmip.core.objects.CurrentAttribute` object containing the existing attribute to modify. Required if the attribute is multivalued.
        * `new_attribute` (struct): A :class:`kmip.core.objects.NewAttribute` object containing the new attribute. Required.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> from kmip.core import objects, primitives
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.modify_attribute(
            ...         unique_identifier="1",
            ...         current_attribute=objects.CurrentAttribute(
            ...             attribute=primitives.TextString(
            ...                 value="Old Object Group",
            ...                 tag=enums.Tags.OBJECT_GROUP
            ...             ),
            ...         ),
            ...         new_attribute=objects.NewAttribute(
            ...             attribute=primitives.TextString(
            ...                 value="New Object Group",
            ...                 tag=enums.Tags.OBJECT_GROUP
            ...             )
            ...         )
            ...     )
            '1'

    .. py:method:: register(managed_object)

        Register a managed object with a KMIP appliance.

        :param managed_object: A :class:`kmip.pie.objects.ManagedObject`
            instance to register with the server.

        :return: The string uid of the newly registered managed object.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Registering an existing 128-bit AES symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     c.register(symmetric_key)
            ...
            '452'

    .. py:method:: rekey(uid=None, offset=None, **kwargs)

        Rekey an existing key.

        :param string uid: The unique ID of the managed object that is the key
            to rekey.
        :param int offset: The time delta, in seconds, between the new key's
            initialization date and activation date.
        :param `**kwargs`: A placeholder for object attributes that
            should be set on the newly rekeyed key.

        :return: The string ID of the newly rekeyed key.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        The current set of supported `kwargs` values are:

        * `activation_date` (int): The new key's activation date, in seconds since the epoch.
        * `process_start_date` (int): The new key's process start date, in seconds since the epoch.
        * `protect_stop_date` (int): The new key's protect stop date, in seconds since the epoch.
        * `deactivation_date` (int): The new key's deactivation date, in seconds since the epoch.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.rekey(
            ...         uid="1",
            ...         offset=60
            ...     )
            "2"

    .. py:method:: revoke(revocation_reason, uid=None, revocation_message=None, compromise_occurrence_date=None)

        Revoke a managed object stored by a KMIP appliance.

        Activated objects must be revoked before they can be destroyed.

        :param revocation_reason: A
            :class:`kmip.core.enums.RevocationReasonCode` enumeration
            indicating the revocation reason. See
            :term:`revocation_reason_code` for more information.
        :param string uid: The unique ID of the managed object to revoke.
            Optional, defaults to None.
        :param string revocation_message: A message regarding the revocation.
            Optional, defaults to None.
        :param int compromise_occurrence_date: An integer, the number of
            seconds since the epoch, which will be converted to the Datetime
            when the managed object was first believed to be compromised.
            Optional, defaults to None.

        :return: None

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Revoking an activated symmetric key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> symmetric_key = objects.SymmetricKey(
            ...     enums.CryptographicAlgorithm.AES,
            ...     128,
            ...     (
            ...         b'\x00\x01\x02\x03\x04\x05\x06\x07'
            ...         b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F'
            ...     )
            ... )
            >>> with c:
            ...     key_id = c.register(symmetric_key)
            ...     c.activate(key_id)
            ...     c.revoke(
            ...         enums.RevocationReasonCode.CESSATION_OF_OPERATION,
            ...         key_id
            ...     )

    .. py:method:: set_attribute(unique_identifier=None, **kwargs)

        Set an attribute on a managed object.

        :param string unique_identifier: The unique ID of the managed object
            on which to set the specified attribute.
        :param `**kwargs`: A placeholder for attribute values used to identify
            the attribute to set. See the example below for more
            information.

        :return: The string ID of the managed object on which the attribute
            was set.

        This operation is supported by KMIP 2.0+ only. The supported `kwargs`
        values are:

        * `attribute_name` (string): The name of the attribute to set. Required.
        * `attribute_value` (various): The value of the attribute to set. Required.

        .. code-block:: python

            >>> from kmip.pie import client
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     c.set_attribute(
            ...         unique_identifier="1",
            ...         attribute_name="Sensitive",
            ...         attribute_value=True
            ...     )
            '1'

    .. py:method:: sign(data, uid=None, cryptographic_parameters=None)

        Create a digital signature for data using the specified signing key.

        :param bytes data: The bytes of the data to be signed. Required.
        :param string uid: The unique ID of the signing key to use. Optional,
            defaults to None.
        :param dict cryptographic_parameters: A dictionary containing various
            cryptographic settings to be used for creating the signature (e.g.,
            cryptographic algorithm, hashing algorithm, and/or digital
            signature algorithm). Optional, defaults to None. See
            :term:`cryptographic_parameters` for more information.

        :return: Bytes representing the signature of the data.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Signing data with a private key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     public_key_id, private_key_id = c.create_key_pair(
            ...         enums.CryptographicAlgorithm.RSA,
            ...         2048,
            ...         public_usage_mask=[
            ...             enums.CryptographicUsageMask.VERIFY
            ...         ],
            ...         private_usage_mask=[
            ...             enums.CryptographicUsageMask.SIGN
            ...         ]
            ...     )
            ...     c.activate(public_key_id)
            ...     c.activate(private_key_id)
            ...     signature = c.sign(
            ...         b'This is a signed message.',
            ...         uid=private_key_id,
            ...         cryptographic_parameters={
            ...             'padding_method': enums.PaddingMethod.PSS,
            ...             'cryptographic_algorithm':
            ...                 enums.CryptographicAlgorithm.RSA,
            ...             'hashing_algorithm': enums.HashingAlgorithm.SHA_256
            ...         }
            ...     )
            ...
            >>> signature
            b'...'

    .. py:method:: signature_verify(message, signature, uid=None, cryptographic_parameters=None)

        Verify a message signature using the specified signing key.

        :param bytes message: The bytes of the signed message. Required.
        :param bytes signature: The bytes of the message signature. Required.
        :param string uid: The unique ID of the signing key to use. Optional,
            defaults to None.
        :param dict cryptographic_parameters: A dictionary containing various
            cryptographic settings to be used for signature verification (e.g.,
            cryptographic algorithm, hashing algorithm, and/or digital
            signature algorithm). Optional, defaults to None. See
            :term:`cryptographic_parameters` for more information.

        :return: A :class:`kmip.core.enums.ValidityIndicator` enumeration
            indicating whether or not the signature was valid.

        :raises kmip.pie.exceptions.ClientConnectionNotOpen: This is raised if
            the client connection is unusable.
        :raises kmip.pie.exceptions.KmipOperationFailure: This is raised if the
            operation result is a failure.
        :raises TypeError: This is raised if the input argument is invalid.

        Verifying a signature with a public key would look like this:

        .. code-block:: python

            >>> from kmip.pie import objects
            >>> from kmip.pie import client
            >>> from kmip import enums
            >>> c = client.ProxyKmipClient()
            >>> with c:
            ...     public_key_id, private_key_id = c.create_key_pair(
            ...         enums.CryptographicAlgorithm.RSA,
            ...         2048,
            ...         public_usage_mask=[
            ...             enums.CryptographicUsageMask.VERIFY
            ...         ],
            ...         private_usage_mask=[
            ...             enums.CryptographicUsageMask.SIGN
            ...         ]
            ...     )
            ...     c.activate(public_key_id)
            ...     c.activate(private_key_id)
            ...     c.signature_verify(
            ...         b'This is a signed message.',
            ...         b'...',
            ...         uid=public_key_id,
            ...         cryptographic_parameters={
            ...             'padding_method': enums.PaddingMethod.PSS,
            ...             'cryptographic_algorithm':
            ...                 enums.CryptographicAlgorithm.RSA,
            ...             'hashing_algorithm': enums.HashingAlgorithm.SHA_256
            ...         }
            ...     )
            ...
            <ValidityIndicator.VALID: 1>

.. _`ssl`: https://docs.python.org/dev/library/ssl.html#socket-creation