Пример #1
0
    def post(self):
        """Handles posting back of data and returns a result via XHR.
       Just for demo purposes.  Accepts a string as data.
    """

        data = self.request.get('data')
        if data:
            logging.info('posted raw string = [%s]', data)
            sig = magicsigalg.SignatureAlgRsaSha256(
                self.signing_key).Sign(data)

            logging.info('resulting signature: [%s]', sig)

            self.response.set_status(200)  # The default
            self.response.out.write('Signed [%s]\n' % data)
            self.response.out.write('With key [%s]\n' % self.signing_key)
            self.response.out.write('Yielding signature [%s]\n' % sig)
        else:
            self.response.set_status(400)
Пример #2
0
# See the License for the specific language governing permissions and
# limitations under the License.
"""Generate a simple signature from known plaintext."""

import magicsig.magicsigalg as magicsigalg

__author__ = '[email protected] (John Panzer)'

_test_keypair = ('RSA.mVgY8RN6URBTstndvmUUPb4UZTdwvwmddSKE5z_jvKUEK6yk1'
                 'u3rrC9yN8k6FilGj9K0eeUPe2hf4Pj-5CmHww=='
                 '.AQAB'
                 '.Lgy_yL3hsLBngkFdDw1Jy9TmSRMiH6yihYetQ8jy-jZXdsZXd8V5'
                 'ub3kuBHHk4M39i3TduIkcrjcsiWQb77D8Q==')

_test_text = unicode(
    'One small splash for a salmon, one giant '
    'leap for salmonkind!', 'utf-8').encode('utf-8')


def log(s):
    print s


if __name__ == '__main__':
    signer = magicsigalg.SignatureAlgRsaSha256(_test_keypair)
    logger = ''
    sig = signer.Sign(_test_text, log)
    print "Message: [%s]" % _test_text
    print "Key: [%s]" % _test_keypair
    print "Signature: [%s]" % sig
Пример #3
0
 def setUp(self):
   # Well known keys to use for testing:
   self.signer = magicsigalg.SignatureAlgRsaSha256(self._test_keypair)
   self.verifier = magicsigalg.SignatureAlgRsaSha256(self._test_publickey)