docs: python bindings and its special request
* Added some material on using the new-ish hkp4py module with GPGME. * Example code will be added later once a couple of little issues are addressed. Signed-off-by: Ben McGinnes <ben@adversary.org>
This commit is contained in:
parent
34be6163f6
commit
5cb67257f2
@ -28,7 +28,7 @@
|
|||||||
* Basic Functions::
|
* Basic Functions::
|
||||||
* Creating keys and subkeys::
|
* Creating keys and subkeys::
|
||||||
* Advanced or Experimental Use Cases::
|
* Advanced or Experimental Use Cases::
|
||||||
* Miscellaneous work-arounds::
|
* Miscellaneous extras and work-arounds::
|
||||||
* Copyright and Licensing::
|
* Copyright and Licensing::
|
||||||
|
|
||||||
@detailmenu
|
@detailmenu
|
||||||
@ -125,9 +125,14 @@ Advanced or Experimental Use Cases
|
|||||||
|
|
||||||
* C plus Python plus SWIG plus Cython::
|
* C plus Python plus SWIG plus Cython::
|
||||||
|
|
||||||
Miscellaneous work-arounds
|
Miscellaneous extras and work-arounds
|
||||||
|
|
||||||
* Group lines::
|
* Group lines::
|
||||||
|
* Keyserver access for Python::
|
||||||
|
|
||||||
|
Keyserver access for Python
|
||||||
|
|
||||||
|
* Key import format::
|
||||||
|
|
||||||
Copyright and Licensing
|
Copyright and Licensing
|
||||||
|
|
||||||
@ -763,7 +768,7 @@ one argument which is a bytes literal object containing either the
|
|||||||
binary or ASCII armoured key data for one or more keys.
|
binary or ASCII armoured key data for one or more keys.
|
||||||
|
|
||||||
The following example retrieves one or more keys from the SKS
|
The following example retrieves one or more keys from the SKS
|
||||||
keyservers via the web using the requests module. Since requests
|
keyservers via the web using the requests module. Since requests
|
||||||
returns the content as a bytes literal object, we can then use that
|
returns the content as a bytes literal object, we can then use that
|
||||||
directly to import the resulting data into our keybox.
|
directly to import the resulting data into our keybox.
|
||||||
|
|
||||||
@ -811,7 +816,7 @@ else:
|
|||||||
|
|
||||||
@strong{NOTE:} When searching for a key ID of any length or a fingerprint
|
@strong{NOTE:} When searching for a key ID of any length or a fingerprint
|
||||||
(without spaces), the SKS servers require the the leading @samp{0x}
|
(without spaces), the SKS servers require the the leading @samp{0x}
|
||||||
indicative of hexadecimal be included. Also note that the old short
|
indicative of hexadecimal be included. Also note that the old short
|
||||||
key IDs (e.g. @samp{0xDEADBEEF}) should no longer be used due to the
|
key IDs (e.g. @samp{0xDEADBEEF}) should no longer be used due to the
|
||||||
relative ease by which such key IDs can be reproduced, as demonstrated
|
relative ease by which such key IDs can be reproduced, as demonstrated
|
||||||
by the Evil32 Project in 2014 (which was subsequently exploited in
|
by the Evil32 Project in 2014 (which was subsequently exploited in
|
||||||
@ -2178,11 +2183,12 @@ The example versions include some additional options to annotate the
|
|||||||
existing code and to detect Cython's use. The latter comes from the
|
existing code and to detect Cython's use. The latter comes from the
|
||||||
@uref{http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd, Magic Attributes} section of the Cython documentation.
|
@uref{http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd, Magic Attributes} section of the Cython documentation.
|
||||||
|
|
||||||
@node Miscellaneous work-arounds
|
@node Miscellaneous extras and work-arounds
|
||||||
@chapter Miscellaneous work-arounds
|
@chapter Miscellaneous extras and work-arounds
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Group lines::
|
* Group lines::
|
||||||
|
* Keyserver access for Python::
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
@node Group lines
|
@node Group lines
|
||||||
@ -2249,6 +2255,32 @@ script reads all the group entries in a user's @samp{gpg.conf} file and
|
|||||||
converts them into crypt-hooks suitable for use with the Mutt and
|
converts them into crypt-hooks suitable for use with the Mutt and
|
||||||
Neomutt mail clients.
|
Neomutt mail clients.
|
||||||
|
|
||||||
|
@node Keyserver access for Python
|
||||||
|
@section Keyserver access for Python
|
||||||
|
|
||||||
|
The @uref{https://github.com/Selfnet/hkp4py, hkp4py} module by Marcel Fest was originally a port of the old
|
||||||
|
@uref{https://github.com/dgladkov/python-hkp, python-hkp} module from Python 2 to Python 3 and updated to use the
|
||||||
|
@uref{http://docs.python-requests.org/en/latest/index.html, requests} module instead. It has since been modified to provide
|
||||||
|
support for Python 2.7 as well and is available via PyPI.
|
||||||
|
|
||||||
|
Since it rewrites the @samp{hkp} protocol prefix as @samp{http} and @samp{hkps} as
|
||||||
|
@samp{https}, the module is able to be used even with servers which do not
|
||||||
|
support the full scope of keyserver functions. It will work quite
|
||||||
|
readily when incorporated into a @ref{C plus Python plus SWIG plus Cython, , Cython} generated and compiled version
|
||||||
|
of any code.
|
||||||
|
|
||||||
|
@menu
|
||||||
|
* Key import format::
|
||||||
|
@end menu
|
||||||
|
|
||||||
|
@node Key import format
|
||||||
|
@subsection Key import format
|
||||||
|
|
||||||
|
The hkp4py module returns key data via requests as string literals
|
||||||
|
(@samp{r.text}) instead of byte literals (@samp{r.content}). This means that
|
||||||
|
the retrurned key data must be encoded to UTF-8 when importing that
|
||||||
|
key material using a @samp{gpg.Context().key_import()} method.
|
||||||
|
|
||||||
@node Copyright and Licensing
|
@node Copyright and Licensing
|
||||||
@chapter Copyright and Licensing
|
@chapter Copyright and Licensing
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ one argument which is a bytes literal object containing either the
|
|||||||
binary or ASCII armoured key data for one or more keys.
|
binary or ASCII armoured key data for one or more keys.
|
||||||
|
|
||||||
The following example retrieves one or more keys from the SKS
|
The following example retrieves one or more keys from the SKS
|
||||||
keyservers via the web using the requests module. Since requests
|
keyservers via the web using the requests module. Since requests
|
||||||
returns the content as a bytes literal object, we can then use that
|
returns the content as a bytes literal object, we can then use that
|
||||||
directly to import the resulting data into our keybox.
|
directly to import the resulting data into our keybox.
|
||||||
|
|
||||||
@ -690,7 +690,7 @@ else:
|
|||||||
|
|
||||||
*NOTE:* When searching for a key ID of any length or a fingerprint
|
*NOTE:* When searching for a key ID of any length or a fingerprint
|
||||||
(without spaces), the SKS servers require the the leading =0x=
|
(without spaces), the SKS servers require the the leading =0x=
|
||||||
indicative of hexadecimal be included. Also note that the old short
|
indicative of hexadecimal be included. Also note that the old short
|
||||||
key IDs (e.g. =0xDEADBEEF=) should no longer be used due to the
|
key IDs (e.g. =0xDEADBEEF=) should no longer be used due to the
|
||||||
relative ease by which such key IDs can be reproduced, as demonstrated
|
relative ease by which such key IDs can be reproduced, as demonstrated
|
||||||
by the Evil32 Project in 2014 (which was subsequently exploited in
|
by the Evil32 Project in 2014 (which was subsequently exploited in
|
||||||
@ -2084,7 +2084,7 @@ existing code and to detect Cython's use. The latter comes from the
|
|||||||
[[http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd][Magic Attributes]] section of the Cython documentation.
|
[[http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd][Magic Attributes]] section of the Cython documentation.
|
||||||
|
|
||||||
|
|
||||||
* Miscellaneous work-arounds
|
* Miscellaneous extras and work-arounds
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: cheats-and-hacks
|
:CUSTOM_ID: cheats-and-hacks
|
||||||
:END:
|
:END:
|
||||||
@ -2157,6 +2157,34 @@ converts them into crypt-hooks suitable for use with the Mutt and
|
|||||||
Neomutt mail clients.
|
Neomutt mail clients.
|
||||||
|
|
||||||
|
|
||||||
|
** Keyserver access for Python
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: hkp4py
|
||||||
|
:END:
|
||||||
|
|
||||||
|
The [[https://github.com/Selfnet/hkp4py][hkp4py]] module by Marcel Fest was originally a port of the old
|
||||||
|
[[https://github.com/dgladkov/python-hkp][python-hkp]] module from Python 2 to Python 3 and updated to use the
|
||||||
|
[[http://docs.python-requests.org/en/latest/index.html][requests]] module instead. It has since been modified to provide
|
||||||
|
support for Python 2.7 as well and is available via PyPI.
|
||||||
|
|
||||||
|
Since it rewrites the =hkp= protocol prefix as =http= and =hkps= as
|
||||||
|
=https=, the module is able to be used even with servers which do not
|
||||||
|
support the full scope of keyserver functions. It will work quite
|
||||||
|
readily when incorporated into a [[#cython][Cython]] generated and compiled version
|
||||||
|
of any code.
|
||||||
|
|
||||||
|
|
||||||
|
*** Key import format
|
||||||
|
:PROPERTIES:
|
||||||
|
:CUSTOM_ID: hkp4py-strings
|
||||||
|
:END:
|
||||||
|
|
||||||
|
The hkp4py module returns key data via requests as string literals
|
||||||
|
(=r.text=) instead of byte literals (=r.content=). This means that
|
||||||
|
the retrurned key data must be encoded to UTF-8 when importing that
|
||||||
|
key material using a =gpg.Context().key_import()= method.
|
||||||
|
|
||||||
|
|
||||||
* Copyright and Licensing
|
* Copyright and Licensing
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: copyright-and-license
|
:CUSTOM_ID: copyright-and-license
|
||||||
|
Loading…
Reference in New Issue
Block a user