X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=doc%2FMCollective%2FSSL.html;fp=doc%2Fclasses%2FMCollective%2FSSL.html;h=9dccae24556e7ab5b539961122274e3893ae5afc;hb=7c9314f502cde8daad23b61d10b24a542e04154a;hp=678945dba14a2a52b8f642fd9dd79a3540144c88;hpb=d1f1649ba43c5cbc43c4beb2380096ba051d646a;p=packages%2Fprecise%2Fmcollective.git diff --git a/doc/classes/MCollective/SSL.html b/doc/MCollective/SSL.html similarity index 53% rename from doc/classes/MCollective/SSL.html rename to doc/MCollective/SSL.html index 678945d..9dccae2 100644 --- a/doc/classes/MCollective/SSL.html +++ b/doc/MCollective/SSL.html @@ -1,85 +1,371 @@ - - - + + - Class: MCollective::SSL - - - - - - - - - - -
- - - - - - - - - + - - - - -
ClassMCollective::SSL
In: - - lib/mcollective/ssl.rb - -
-
Parent: - Object -
-
- + Class: MCollective::SSL -
+ + + + + - -
- -
-

+ + + +

+
+
+

In Files

+ +
+ + +
+ + + +
+ + + + + +
+

Class Index + [+]

+
+
+ Quicksearch + +
+
+ + + +
+ + +
+
+ +
+

MCollective::SSL

+ +
+

A class that assists in encrypting and decrypting data using a combination of RSA and AES

@@ -106,7 +392,7 @@ This will result in a hash of data like:

The key and data will all be base 64 encoded already by default you can pass a 2nd parameter as false to encrypt_with_private and counterparts that will +href="SSL.html#M000206">encrypt_with_private and counterparts that will prevent the base 64 encoding

@@ -118,162 +404,186 @@ There are matching methods for using a public key to encrypt data to be decrypted using a private key

-
- - -
- - - -
- - - - -
- - - - - -
-

Attributes

- -
- - - - - - - - - - - - - - - - -
private_key_file [R] 
public_key_file [R] 
ssl_cipher [R] 
-
-
- - - - -
-

Public Class methods

- -
- - - - -
-

[Source]

-
+
+ + + + + + +
+

Attributes

+ + +
+ + +
+ public_key_file[R] +
+ +
+ +

(Not documented)

+ +
+
+ +
+ + +
+ private_key_file[R] +
+ +
+ +

(Not documented)

+ +
+
+ +
+ + +
+ ssl_cipher[R] +
+ +
+ +

(Not documented)

+ +
+
+ +
+ + + + +
+

Public Class Methods

+ + +
+ + +
+ + base64_decode(string) + click to toggle source + +
+ +
+ +

(Not documented)

+ + + +
      # File lib/mcollective/ssl.rb, line 195
 195:     def self.base64_decode(string)
 196:       Base64.decode64(string)
-197:     end
-
-
-
-
- -
- - - - -
-

[Source]

-
+197: end +
+ +
+ + +
+ + +
+ + +
+ + base64_encode(string) + click to toggle source + +
+ +
+ +

(Not documented)

+ + + +
      # File lib/mcollective/ssl.rb, line 186
 186:     def self.base64_encode(string)
 187:       Base64.encode64(string)
-188:     end
-
-
-
-
- -
- - - - -
-

[Source]

-
+188: end +
+ +
+ + +
+ + +
+ + +
+ + md5(string) + click to toggle source + +
+ +
+ +

(Not documented)

+ + + +
      # File lib/mcollective/ssl.rb, line 203
 203:     def self.md5(string)
 204:       Digest::MD5.hexdigest(string)
-205:     end
-
-
-
-
- - + + +
+ + +
+ + new(pubkey=nil, privkey=nil, passphrase=nil, cipher=nil) + click to toggle source + +
+ +
+ +

(Not documented)

+ + + +
     # File lib/mcollective/ssl.rb, line 37
 37:     def initialize(pubkey=nil, privkey=nil, passphrase=nil, cipher=nil)
@@ -288,23 +598,29 @@ decrypted using a private key
 46:       @ssl_cipher = cipher if cipher
 47: 
 48:       raise "The supplied cipher '#{@ssl_cipher}' is not supported" unless OpenSSL::Cipher.ciphers.include?(@ssl_cipher)
-49:     end
-
-
-
-
- -
- - - - -
-

+49: end +

+ +
+ + +
+ + +
+ + +
+ + uuid(string=nil) + click to toggle source + +
+ +
+ +

Creates a RFC 4122 version 5 UUID. If string is supplied it will produce repeatable UUIDs for that string else a random 128bit string will be used from OpenSSL::BN @@ -315,9 +631,11 @@ Code used with permission from:

    https://github.com/kwilczynski/puppet-functions/blob/master/lib/puppet/parser/functions/uuid.rb
 
-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 213
 213:     def self.uuid(string=nil)
@@ -345,30 +663,42 @@ Code used with permission from:
 235:       end
 236: 
 237:       bytes.join('-')
-238:     end
-
-
-
-
- -

Public Instance methods

- -
- - - - -
-

+238: end +

+ +
+ + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ + +
+ + aes_decrypt(key, crypt_string) + click to toggle source + +
+ +
+ +

decrypts a string given key, iv and data

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 158
 158:     def aes_decrypt(key, crypt_string)
@@ -378,28 +708,36 @@ decrypts a string given key, iv and data
 162:       cipher.key = key
 163:       cipher.pkcs5_keyivgen(key)
 164:       decrypted_data = cipher.update(crypt_string) + cipher.final
-165:     end
-
-
-
-
- -
- - - - -
-

+165: end +

+ +
+ + +
+ + +
+ + +
+ + aes_encrypt(plain_string) + click to toggle source + +
+ +
+ +

encrypts a string, returns a hash of key, iv and data

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 144
 144:     def aes_encrypt(plain_string)
@@ -413,80 +751,104 @@ encrypts a string, returns a hash of key, iv and data
 152:       encrypted_data = cipher.update(plain_string) + cipher.final
 153: 
 154:       {:key => key, :data => encrypted_data}
-155:     end
-
-
-
-
- -
- - - - -
-

+155: end +

+ +
+ + +
+ + +
+ + +
+ + base64_decode(string) + click to toggle source + +
+ +
+ +

base 64 decode a string

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 191
 191:     def base64_decode(string)
 192:       SSL.base64_decode(string)
-193:     end
-
-
-
-
- -
- - - - -
-

+193: end +

+ +
+ + +
+ + +
+ + +
+ + base64_encode(string) + click to toggle source + +
+ +
+ +

base 64 encode a string

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 182
 182:     def base64_encode(string)
 183:       SSL.base64_encode(string)
-184:     end
-
-
-
-
- -
- - - - -
-

+184: end +

+ +
+ + +
+ + +
+ + +
+ + decrypt_with_private(crypted, base64=true) + click to toggle source + +
+ +
+ +

Decrypts data, expects a hash as create with crypt_with_public

-

[Source]

-
+ + + +
     # File lib/mcollective/ssl.rb, line 88
 88:     def decrypt_with_private(crypted, base64=true)
@@ -500,28 +862,36 @@ Decrypts data, expects a hash as create with crypt_with_public
 96:         key = rsa_decrypt_with_private(crypted[:key])
 97:         aes_decrypt(key, crypted[:data])
 98:       end
-99:     end
-
-
-
-
- - + + +
+ + +
+ + +
+ + decrypt_with_public(crypted, base64=true) + click to toggle source + +
+ +
+ +

Decrypts data, expects a hash as create with crypt_with_private

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 102
 102:     def decrypt_with_public(crypted, base64=true)
@@ -535,31 +905,39 @@ Decrypts data, expects a hash as create with crypt_with_private
 110:         key = rsa_decrypt_with_public(crypted[:key])
 111:         aes_decrypt(key, crypted[:data])
 112:       end
-113:     end
-
-
-
-
- - + + +
+ + +
+ + +
+ + encrypt_with_private(plain_text, base64=true) + click to toggle source + +
+ +
+ +

Encrypts supplied data using AES and then encrypts using RSA the key and IV

Return a hash with everything optionally base 64 encoded

-

[Source]

-
+ + + +
     # File lib/mcollective/ssl.rb, line 73
 73:     def encrypt_with_private(plain_text, base64=true)
@@ -574,31 +952,39 @@ Return a hash with everything optionally base 64 encoded
 82:       end
 83: 
 84:       {:key => key, :data => data}
-85:     end
-
-
-
-
- - + + +
+ + +
+ + +
+ + encrypt_with_public(plain_text, base64=true) + click to toggle source + +
+ +
+ +

Encrypts supplied data using AES and then encrypts using RSA the key and IV

Return a hash with everything optionally base 64 encoded

-

[Source]

-
+ + + +
     # File lib/mcollective/ssl.rb, line 55
 55:     def encrypt_with_public(plain_text, base64=true)
@@ -613,52 +999,69 @@ Return a hash with everything optionally base 64 encoded
 64:       end
 65: 
 66:       {:key => key, :data => data}
-67:     end
-
-
-
-
- -
- - - - -
-

[Source]

-
+67: end +
+ +
+ + +
+ + +
+ + +
+ + md5(string) + click to toggle source + +
+ +
+ +

(Not documented)

+ + + +
      # File lib/mcollective/ssl.rb, line 199
 199:     def md5(string)
 200:       SSL.md5(string)
-201:     end
-
-
-
-
- -
- - - - -
-

+201: end +

+ +
+ + +
+ + +
+ + +
+ + read_key(type, key=nil, passphrase=nil) + click to toggle source + +
+ +
+ +

Reads either a :public or :private key from disk, uses an optional passphrase to read the private key

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 242
 242:     def read_key(type, key=nil, passphrase=nil)
@@ -696,191 +1099,250 @@ passphrase to read the private key
 274:       else
 275:         raise "Can only load :public or :private keys"
 276:       end
-277:     end
-
-
-
-
- -
- - - - -
-

+277: end +

+ +
+ + +
+ + +
+ + +
+ + rsa_decrypt_with_private(crypt_string) + click to toggle source + +
+ +
+ +

Use the private key to RSA decrypt data

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 123
 123:     def rsa_decrypt_with_private(crypt_string)
 124:       raise "No private key set" unless @private_key
 125: 
 126:       @private_key.private_decrypt(crypt_string)
-127:     end
-
-
-
-
- -
- - - - -
-

+127: end +

+ +
+ + +
+ + +
+ + +
+ + rsa_decrypt_with_public(crypt_string) + click to toggle source + +
+ +
+ +

Use the public key to RSA decrypt data

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 137
 137:     def rsa_decrypt_with_public(crypt_string)
 138:       raise "No public key set" unless @public_key
 139: 
 140:       @public_key.public_decrypt(crypt_string)
-141:     end
-
-
-
-
- -
- - - - -
-

+141: end +

+ +
+ + +
+ + +
+ + +
+ + rsa_encrypt_with_private(plain_string) + click to toggle source + +
+ +
+ +

Use the private key to RSA encrypt data

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 130
 130:     def rsa_encrypt_with_private(plain_string)
 131:       raise "No private key set" unless @private_key
 132: 
 133:       @private_key.private_encrypt(plain_string)
-134:     end
-
-
-
-
- -
- - - - -
-

+134: end +

+ +
+ + +
+ + +
+ + +
+ + rsa_encrypt_with_public(plain_string) + click to toggle source + +
+ +
+ +

Use the public key to RSA encrypt data

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 116
 116:     def rsa_encrypt_with_public(plain_string)
 117:       raise "No public key set" unless @public_key
 118: 
 119:       @public_key.public_encrypt(plain_string)
-120:     end
-
-
-
-
- -
- - - - -
-

+120: end +

+ +
+ + +
+ + +
+ + +
+ + sign(string, base64=false) + click to toggle source + +
+ +
+ +

Signs a string using the private key

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 168
 168:     def sign(string, base64=false)
 169:       sig = @private_key.sign(OpenSSL::Digest::SHA1.new, string)
 170: 
 171:       base64 ? base64_encode(sig) : sig
-172:     end
-
-
-
-
- - + + +
+ + +
+ + +
+ + verify_signature(signature, string, base64=false) + click to toggle source + +
+ +
+ +

Using the public key verifies that a string was signed using the private key

-

[Source]

-
+ + + +
      # File lib/mcollective/ssl.rb, line 175
 175:     def verify_signature(signature, string, base64=false)
 176:       signature = base64_decode(signature) if base64
 177: 
 178:       @public_key.verify(OpenSSL::Digest::SHA1.new, signature, string)
-179:     end
-
-
-
-
+179: end +
+ +
+ +
-
+ +
+ +
-
+
+ +

Disabled; run with --debug to generate this.

+ +
-
-

[Validate]

-
+
+

[Validate]

+

Generated with the Darkfish + Rdoc Generator 1.1.6.

+
- \ No newline at end of file + +