Skip to content

Commit 587b607

Browse files
committed
Updated documentation.
1 parent 91320cc commit 587b607

File tree

1 file changed

+78
-31
lines changed

1 file changed

+78
-31
lines changed

doc/keyhandling.rst

Lines changed: 78 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,16 @@ only know how to serialize into the format described in JWK_.
9393
>>> rsa_key = new_rsa_key()
9494
>>> rsa_key.serialize()
9595
{
96-
'kty': 'RSA',
97-
'kid': 'NXhZYllJOXdLSW50aUVkcGY4XzZrSVF5blI5aEYxeEJDdFZLV2tHZDlFUQ',
98-
'n': 'xRgpX7q-kvQ02EhkHi63TQBR0RMcGCnxCugxtcPmaIX8brilwbkwQyZraEHzW
99-
zj-gaQyro_dWR7QqbhgiQ6U9Hj3x6HINJuw7LbqR_GE4TvTu3rJXPh3MqTs7yK6GcgK
100-
soTv8wQy6Pwl7gjrQRk37zfIHWLkxU-crz2dd1QdSmStlxRjbczik66llF5ENXE3wVz
101-
raPAdjIv1Y4n5dT3kw7QerVv2Dntn5TJ_8QSkmDJW-FA2TQbKBnOd_OgYeKZnGx5cng
102-
uWa23uQZTxfGnE7IXA2XYpZhHIgAGMXQ0SaR07MwIZDmreI_Mxypg2ES7XT42qhnxXU
103-
iGm9fA8nhHjwQ',
104-
'e': 'AQAB'
96+
'kty': 'RSA',
97+
'kid': 'NXhZYllJOXdLSW50aUVkcGY4XzZrSVF5blI5aEYxeEJDdFZLV2tHZDlFUQ',
98+
'n':
99+
'xRgpX7q-kvQ02EhkHi63TQBR0RMcGCnxCugxtcPmaIX8brilwbkwQyZraEHzWzj-g
100+
aQyro_dWR7QqbhgiQ6U9Hj3x6HINJuw7LbqR_GE4TvTu3rJXPh3MqTs7yK6GcgKso
101+
Tv8wQy6Pwl7gjrQRk37zfIHWLkxU-crz2dd1QdSmStlxRjbczik66llF5ENXE3wVz
102+
raPAdjIv1Y4n5dT3kw7QerVv2Dntn5TJ_8QSkmDJW-FA2TQbKBnOd_OgYeKZnGx5c
103+
nguWa23uQZTxfGnE7IXA2XYpZhHIgAGMXQ0SaR07MwIZDmreI_Mxypg2ES7XT42qh
104+
nxXUiGm9fA8nhHjwQ',
105+
'e': 'AQAB'
105106
}
106107

107108

@@ -112,27 +113,31 @@ You can also get the values for the private key like this::
112113
>>> rsa_key = new_rsa_key()
113114
>>> rsa_key.serialize(private=True)
114115
{
115-
'kty': 'RSA',
116-
'kid': 'NXhZYllJOXdLSW50aUVkcGY4XzZrSVF5blI5aEYxeEJDdFZLV2tHZDlFUQ',
117-
'n': 'xRgpX7q-kvQ02EhkHi63TQBR0RMcGCnxCugxtcPmaIX8brilwbkwQyZraEHz
118-
Wzj-gaQyro_dWR7QqbhgiQ6U9Hj3x6HINJuw7LbqR_GE4TvTu3rJXPh3MqTs7yK6Gc
119-
gKsoTv8wQy6Pwl7gjrQRk37zfIHWLkxU-crz2dd1QdSmStlxRjbczik66llF5ENXE3
120-
wVzraPAdjIv1Y4n5dT3kw7QerVv2Dntn5TJ_8QSkmDJW-FA2TQbKBnOd_OgYeKZnGx
121-
5cnguWa23uQZTxfGnE7IXA2XYpZhHIgAGMXQ0SaR07MwIZDmreI_Mxypg2ES7XT42q
122-
hnxXUiGm9fA8nhHjwQ',
123-
'e': 'AQAB',
124-
'd': 's-2jz73WvqdsGsqzg45YTlZtWrXcXv7jC3b_8pTdoiw3UAkHYXwjYBoR0cLr
125-
XCsCxO1WS2AQzYxBJ7-neVezih9o7Hl4IPbFJMSzymvlSA1q9OtaKqK1hqljl8gXJv
126-
QlN-X-e9coduPB6LWBtxNDqgI9kP44JRzRyHUybL6AYuk970_RoqxH2nr8FqMZbNWl
127-
Vk2X-v06EcO4E_ROSl8vqpb811UidXIvWAJw36LAUw0BTpdvpejSVM1B7PZWbzD91T
128-
4vwJYOAVdwWxpmA5HEXRbpNJLnMJus7iq7EVyG2ZbA4TXT-EIoASKMyxJtAuKMDk6c
129-
SISWay6LwjdBgVMAAQ',
130-
'p': '588dwE505-i7wL5mWkhH19xS1RzKahFhA66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pejSVM1B7PZWbzD9
131+
1T4vwJYOAVdwWxpmA5HEXRbpNJLnMJus7iq7EVyG2ZbA4TXT-EIoASKMyxJtAuKM
132+
Dk6cSISWay6LwjdBgVMAAQ',
133+
'p':
134+
'588dwE505-i7wL5mWkhH19xS1RzKahFhA66ZVmPjBaA88TBlaZxsdqEADwqXoMq_
135+
XIUh-P5Tc-ueiCw5rUVNTMb45HWr5fnQXtnJt4yMukNpERABIcWvZWLQg_ONW4iA
136+
Kid9MLg5EYd2VkAAwXwzzdD1hiYEcxMwQVQ3nLmQ8AE',
137+
'q':
138+
'2amgmjQD5Jx7kAR-9oLFjnuvgbUMBOUieQKUCpeJu8q00S7kHb2Hy6ZsanJ--Biu
139+
1XKz1lxelpN2upsjiKU7f08PB_IPCenBZIU3YwozZd15wCoSyKtffgqk5RXeyi3I
140+
1ULKXHxr3L7g-7Yi_APgtInQncNnm0Q_t7A_c-P888E'
136141
}
137142

138143
And you can of course create a key from a JWK representation::
@@ -155,7 +160,49 @@ Key bundle
155160
As mentioned above a key bundle is used to manage keys that have a common
156161
origin.
157162

158-
You can initiate a key bundle in serveral ways.
163+
You can initiate a key bundle in serveral ways. You can use all the
164+
import variants we described above and then add the resulting key to a key
165+
bundle::
166+
167+
>>> from cryptojwt.jwk.ec import ECKey
168+
>>> from cryptojwt.key_bundle import KeyBundle
169+
>>> ec_key = ECKey().load('ec-keypair.pem')
170+
>>> kb = KeyBundle()
171+
>>> kb.append(ec_key)
172+
>>> len(kb)
173+
1
174+
>>> rsa_key = new_rsa_key()
175+
>>> kb.append(rsa_key)
176+
>>> len(kb)
177+
2
178+
>>> kb.jwks()
179+
{"keys":
180+
[
181+
{
182+
"kty": "EC",
183+
"crv": "B-571",
184+
"x":
185+
"AhnRFzRjeOyo-qqm1HPe2JIC69McD29SKAzaBSMzpiRMqh8_tFGWzh2q3pozv_V
186+
4tsWDgl2H0NdLjNTUQV6JlBn52tJBgCYC",
187+
"y":
188+
"LU86ZrZlKMvposLYkgaJrtwklHumK1b1m_joq5r8NsdwQkyVtl44cucurQz1UUc
189+
oYNJ4ecJv1MWb-I6OwGbiVfM7WSsAhAA",
190+
},
191+
{
192+
"kty": "RSA",
193+
"kid":
194+
"cjBobXZ6UHVVdkFmaEJIQXNLbklNNjBMbHo5cWM4U2VjOFRrRkM4RzNaZw",
195+
"e": "AQAB",
196+
"n":
197+
"pyyKp3Fv5ZmyHInUjdEskmI5A-4R19gmzy8SL5waAPd7DMtndQoa-MyMPVP1je
198+
BPdM_WP17bm1IKt3AWIDpXPq2g0KQxiUU6X9hP738CZaqSmff_hiiT0I3VzsUT
199+
1SHhdIAeFIeUeuH8RusWo1NnxT7iXRFHbXsG2EOnxr-xB9FZUgMenU4dBIHh2h
200+
CUW6EZBsYBWuSTyMwRrNp_ZkrH5VJZSCke7bMvlyLlgMFOoDqhuibxEdRmVJAL
201+
7KkfKQjC0OAd6BXrTk1es590MtMsAIIdKXbgcvxZKeGYSjJ8p8HXLelz50uBhh
202+
eJdbUmx7MDWCTgouTGzxDaJuCbAR5wMQ",
203+
}
204+
]
205+
}
159206

160207

161208
Key Jar

0 commit comments

Comments
 (0)