Skip to content

Commit

Permalink
Merge pull request #48 from jtimberman/larger-key-size
Browse files Browse the repository at this point in the history
Addresses #46, use securerandom to generate secret
  • Loading branch information
moserke committed Sep 18, 2013
2 parents 5cb99c4 + 1f577b9 commit 772f024
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/chef-vault/item.rb
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'securerandom'

class ChefVault::Item < Chef::DataBagItem
attr_accessor :keys
attr_accessor :encrypted_data_bag_item
Expand Down Expand Up @@ -131,8 +133,10 @@ def rotate_keys!
reload_raw_data
end

def generate_secret
OpenSSL::PKey::RSA.new(245).to_pem.lines.to_a[1..-2].join
def generate_secret(key_size=32)
# Defaults to 32 bytes, as this is the size that a Chef
# Encrypted Data Bag Item will digest all secrets down to anyway
SecureRandom.random_bytes(key_size)
end

def []=(key, value)
Expand Down

0 comments on commit 772f024

Please sign in to comment.