| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Functions to produce and verify RSA+SHA256 signatures. | 5 """Functions to produce and verify RSA+SHA256 signatures. |
| 6 | 6 |
| 7 Based on app_identity.sign_blob() and app_identity.get_public_certificates() | 7 Based on app_identity.sign_blob() and app_identity.get_public_certificates() |
| 8 functions, and thus private keys are managed by GAE. | 8 functions, and thus private keys are managed by GAE. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import base64 | 11 import base64 |
| 12 import json | 12 import json |
| 13 import logging | 13 import logging |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 # Extract subjectPublicKeyInfo field from X.509 certificate (see RFC3280). | 253 # Extract subjectPublicKeyInfo field from X.509 certificate (see RFC3280). |
| 254 cert = asn1.DerSequence() | 254 cert = asn1.DerSequence() |
| 255 cert.decode(der) | 255 cert.decode(der) |
| 256 tbsCertificate = asn1.DerSequence() | 256 tbsCertificate = asn1.DerSequence() |
| 257 tbsCertificate.decode(cert[0]) | 257 tbsCertificate.decode(cert[0]) |
| 258 subjectPublicKeyInfo = tbsCertificate[6] | 258 subjectPublicKeyInfo = tbsCertificate[6] |
| 259 | 259 |
| 260 verifier = PKCS1_v1_5.new(RSA.importKey(subjectPublicKeyInfo)) | 260 verifier = PKCS1_v1_5.new(RSA.importKey(subjectPublicKeyInfo)) |
| 261 return verifier.verify(SHA256.new(blob), signature) | 261 return verifier.verify(SHA256.new(blob), signature) |
| OLD | NEW |