components/openstack/glance/patches/01-nopycrypto.patch
branchs11u2-sru
changeset 4156 4b1def16fe9b
parent 3178 77584387a894
child 5405 66fd59fecd68
equal deleted inserted replaced
4146:097063f324c0 4156:4b1def16fe9b
     2 Solaris-specific and not suitable for upstream.
     2 Solaris-specific and not suitable for upstream.
     3 
     3 
     4 Convert urlsafe_encrypt() and urlsafe_decrypt() to use M2Crypto instead
     4 Convert urlsafe_encrypt() and urlsafe_decrypt() to use M2Crypto instead
     5 of PyCrypto.
     5 of PyCrypto.
     6 
     6 
     7 --- glance-2013.2.3/glance/common/crypt.py.orig	2014-04-03 11:43:55.000000000 -0700
     7 --- glance-2014.2.2/glance/common/crypt.py.~1~	2014-08-07 12:01:58.000000000 -0700
     8 +++ glance-2013.2.3/glance/common/crypt.py	2014-05-19 03:47:07.005226253 -0700
     8 +++ glance-2014.2.2/glance/common/crypt.py	2014-08-09 21:36:53.351345980 -0700
     9 @@ -4,6 +4,8 @@
     9 @@ -3,6 +3,8 @@
    10  # Copyright 2011 OpenStack LLC.
    10  # Copyright 2011 OpenStack Foundation
    11  # All Rights Reserved.
    11  # All Rights Reserved.
    12  #
    12  #
    13 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    13 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    14 +#
    14 +#
    15  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    15  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    16  #    not use this file except in compliance with the License. You may obtain
    16  #    not use this file except in compliance with the License. You may obtain
    17  #    a copy of the License at
    17  #    a copy of the License at
    18 @@ -21,10 +23,26 @@
    18 @@ -20,10 +22,26 @@
    19  """
    19  """
    20  
    20  
    21  import base64
    21  import base64
    22 +import os
    22 +import os
    23 +
    23 +
    43 +        raise exception.Invalid(msg)
    43 +        raise exception.Invalid(msg)
    44 +    return aes_algs[keylen]
    44 +    return aes_algs[keylen]
    45  
    45  
    46  
    46  
    47  def urlsafe_encrypt(key, plaintext, blocksize=16):
    47  def urlsafe_encrypt(key, plaintext, blocksize=16):
    48 @@ -36,20 +54,12 @@
    48 @@ -35,20 +53,12 @@
    49  
    49  
    50      :returns : Resulting ciphertext
    50      :returns : Resulting ciphertext
    51      """
    51      """
    52 -    def pad(text):
    52 -    def pad(text):
    53 -        """
    53 -        """
    68 +    padded = cipher.update(str(plaintext))
    68 +    padded = cipher.update(str(plaintext))
    69 +    padded = padded + cipher.final()
    69 +    padded = padded + cipher.final()
    70      return base64.urlsafe_b64encode(init_vector + padded)
    70      return base64.urlsafe_b64encode(init_vector + padded)
    71  
    71  
    72  
    72  
    73 @@ -63,6 +73,7 @@
    73 @@ -62,6 +72,7 @@
    74      """
    74      """
    75      # Cast from unicode
    75      # Cast from unicode
    76      ciphertext = base64.urlsafe_b64decode(str(ciphertext))
    76      ciphertext = base64.urlsafe_b64decode(str(ciphertext))
    77 -    cypher = AES.new(key, AES.MODE_CBC, ciphertext[:16])
    77 -    cypher = AES.new(key, AES.MODE_CBC, ciphertext[:16])
    78 -    padded = cypher.decrypt(ciphertext[16:])
    78 -    padded = cypher.decrypt(ciphertext[16:])