Beispiel #1
0
    def test_from_dict(self):
        inst = self.target.from_dict(self.jwk)

        self.assertEqual(inst.kty, 'RSA')
        self.assertEqual(inst.kid, '2011-04-29')
        self.assertEqual(int_to_base64(inst.n), self.jwk['n'])
        self.assertEqual(int_to_base64(inst.e), self.jwk['e'])
        self.assertEqual(int_to_base64(inst.d), self.jwk['d'])
        self.assertEqual(dict(inst), {
            'alg': 'RS256',
            'p': '83i-7IvMGXoMXCskv73TKr8637FiO7Z27zv8oj6pbWUQyLPQBQxtPVnwD20R'
                 '-60eTDmD2ujnMt5PoqMrm8RfmNhVWDtjjMmCMjOpSXicFHj7XOuVIYQyqVWl'
                 'WEh6dN36GVZYk93N8Bc9vY41xy8B9RzzOGVQzXvNEvn7O0nVbfs',
            'q': '3dfOR9cuYq-0S-mkFLzgItgMEfFzB2q3hWehMuG0oCuqnb3vobLyumqjVZQO'
                 '1dIrdwgTnCdpYzBcOfW5r370AFXjiWft_NGEiovonizhKpo9VVS78TzFgxkI'
                 'drecRezsZ-1kYd_s1qDbxtkDEgfAITAG9LUnADun4vIcb6yelxk',
            'dp': 'G4sPXkc6Ya9y8oJW9_ILj4xuppu0lzi_H7VTkS8xj5SdX3coE0oimYwxIi2'
                  'emTAue0UOa5dpgFGyBJ4c8tQ2VF402XRugKDTP8akYhFo5tAA77Qe_NmtuY'
                  'Zc3C3m3I24G2GvR5sSDxUyAN2zq8Lfn9EUms6rY3Ob8YeiKkTiBj0',
            'dq': 's9lAH9fggBsoFR8Oac2R_E2gw282rT2kGOAhvIllETE1efrA6huUUvMfBcM'
                  'pn8lqeW6vzznYY5SSQF7pMdC_agI3nG8Ibp1BUb0JUiraRNqUfLhcQb_d9G'
                  'F4Dh7e74WbRsobRonujTYN1xCaP6TO61jvWrX-L18txXw494Q_cgk',
            'qi': 'GyM_p6JrXySiz1toFgKbWV-JdI3jQ4ypu9rbMWx3rQJBfmt0FoYzgUIZEVF'
                  'EcOqwemRN81zoDAaa-Bk0KWNGDjJHZDdDmFhW3AN7lI-puxk_mHZGJ11rxy'
                  'R8O55XLSe3SPmRfKwZI6yU24ZxvQKFYItdldUKGzO6Ia6zTKhAVRU',
        })
Beispiel #2
0
    def to_dict(self):
        D = super(RSAKey, self).to_dict()
        D["n"] = int_to_base64(self.n)
        D["e"] = int_to_base64(self.e)

        if self.d:
            D["d"] = int_to_base64(self.d)

        return D
Beispiel #3
0
    def to_dict(self):
        D = super(RSAKey, self).to_dict()
        D['n'] = int_to_base64(self.n)
        D['e'] = int_to_base64(self.e)

        if self.d:
            D['d'] = int_to_base64(self.d)

        return D
Beispiel #4
0
 def test_int_to_base64(self):
     self.assertEqual(utils.int_to_base64(65537), 'AQAB')