Browse files

Changing lenght of encoding key string.

Change-Id: Ia7fd41f02959c063d4c6db4efef1a1e742902179
  • Loading branch information...
1 parent 81486f9 commit 695d9fb7a3b27f9ae0052f42bf2878a9b702f9a9 @skraynev skraynev committed Jan 24, 2013
View
8 swift/common/key_manager/drivers/sql/driver.py
@@ -36,10 +36,10 @@
meta = MetaData()
key_info_table = Table("key_info", meta,
- Column('account', String(30)),
+ Column('account', String(42)),
Column('key_id', Integer, primary_key=True,
autoincrement=True),
- Column('encryption_key', String(30)))
+ Column('encryption_key', String(42)))
class SQLDriver(base.KeyDriver):
@@ -137,7 +137,7 @@ def get_key(self, key_id):
# For openssl standart key consist of 16 hex chars
key = os.urandom(16)
# change format for store key in database
- enc_key = base64.b64encode(key)
+ enc_key = base64.b16encode(key)
# check connection to database
self.reconnect_to_db()
# select key_id column
@@ -148,7 +148,7 @@ def get_key(self, key_id):
update_method.execute(encryption_key=enc_key)
return key
- key = base64.b64decode(re[0][2])
+ key = base64.b16decode(re[0][2])
return key
def find_value(self, col_name, val):
View
29 swift/common/key_manager/drivers/sql/migrate_repo/versions/002_Change_size_of_columns.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2010-2012 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from sqlalchemy import MetaData, Table, Column, String, Integer
+
+
+def upgrade(migrate_engine):
+ meta = MetaData(bind=migrate_engine)
+ table = Table('key_info', meta, autoload=True)
+ table.c.account.alter(type=String(42))
+ table.c.encryption_key.alter(type=String(42))
+
+
+def downgrade(migrate_engine):
+ meta = MetaData(bind=migrate_engine)
+ table = Table('key_info', meta, autoload=True)
+ table.c.account.alter(type=String(30))
+ table.c.encryption_key.alter(type=String(30))

0 comments on commit 695d9fb

Please sign in to comment.