Add a key as a subkey to this key. :param key: A private :py:obj:`~pgpy.PGPKey` that does not have any subkeys of its own :keyword usage: A ``set`` of key usage flags, as :py:obj:`~constants.KeyFlags` for the subkey to be added. :type usage: ``set`` Other v
(self, key, **prefs)
| 1864 | self._uids.remove(u) |
| 1865 | |
| 1866 | def add_subkey(self, key, **prefs): |
| 1867 | """ |
| 1868 | Add a key as a subkey to this key. |
| 1869 | |
| 1870 | :param key: A private :py:obj:`~pgpy.PGPKey` that does not have any subkeys of its own |
| 1871 | :keyword usage: A ``set`` of key usage flags, as :py:obj:`~constants.KeyFlags` for the subkey to be added. |
| 1872 | :type usage: ``set`` |
| 1873 | |
| 1874 | Other valid optional keyword arguments are identical to those of self-signatures for :py:meth:`PGPKey.certify` |
| 1875 | """ |
| 1876 | if self.is_public: |
| 1877 | raise PGPError("Cannot add a subkey to a public key. Add the subkey to the private component first!") |
| 1878 | |
| 1879 | if key.is_public: |
| 1880 | raise PGPError("Cannot add a public key as a subkey to this key") |
| 1881 | |
| 1882 | if key.is_primary: |
| 1883 | if len(key._children) > 0: |
| 1884 | raise PGPError("Cannot add a key that already has subkeys as a subkey!") |
| 1885 | |
| 1886 | # convert key into a subkey |
| 1887 | npk = PrivSubKeyV4() |
| 1888 | npk.pkalg = key._key.pkalg |
| 1889 | npk.created = key._key.created |
| 1890 | npk.keymaterial = key._key.keymaterial |
| 1891 | key._key = npk |
| 1892 | key._key.update_hlen() |
| 1893 | |
| 1894 | self._children[key.fingerprint.keyid] = key |
| 1895 | key._parent = self |
| 1896 | |
| 1897 | ##TODO: skip this step if the key already has a subkey binding signature |
| 1898 | bsig = self.bind(key, **prefs) |
| 1899 | key |= bsig |
| 1900 | |
| 1901 | def _get_key_flags(self, user=None): |
| 1902 | if self.is_primary: |