ext/polarssl/cipher.c in polarssl-0.0.6 vs ext/polarssl/cipher.c in polarssl-0.0.7

- old
+ new

@@ -129,13 +129,13 @@ /* Document-class: PolarSSL::Cipher::UnsupportedCipher * Raised when you do not pass a supported cipher type to PolarSSL::Cipher.new() */ e_UnsupportedCipher = rb_define_class_under( cCipher, "UnsupportedCipher", rb_eStandardError ); - + /* Document-class: PolarSSL::Cipher::BadInputData - * Raised when the input data for the cipher was incorrect. If you get + * Raised when the input data for the cipher was incorrect. If you get * this exception, please file a bug report. */ e_BadInputData = rb_define_class_under( cCipher, "BadInputData", rb_eStandardError ); /* Document-class: PolarSSL::Cipher::Error @@ -178,11 +178,11 @@ { rb_cipher_t *rb_cipher; char *cipher_type_str; const cipher_info_t *cipher_info; int ret; - + Check_Type( cipher_type, T_STRING ); cipher_type_str = StringValueCStr( cipher_type ); Data_Get_Struct( self, rb_cipher_t, rb_cipher ); @@ -191,11 +191,11 @@ if (cipher_info == NULL) { rb_raise(e_UnsupportedCipher, "%s is not a supported cipher", cipher_type_str ); } - else + else { ret = cipher_init_ctx( rb_cipher->ctx, cipher_info ); if ( ret < 0 ) rb_raise( e_CipherError, "PolarSSL error: -0x%x", -ret ); } @@ -213,29 +213,29 @@ * This method needs to be called before you run the first #update. * * One option to generate a random initialization vector is by using * SecureRandom.random_bytes. Store this initialization vector with the * ciphertext and you'll easily able to decrypt the ciphertext. - * + * */ VALUE rb_cipher_reset( VALUE self, VALUE initialization_vector ) { rb_cipher_t *rb_cipher; unsigned char *iv; int ret; - + Check_Type( initialization_vector, T_STRING ); - - iv = (unsigned char *) StringValueCStr( initialization_vector ); - + + iv = (unsigned char *) StringValuePtr( initialization_vector ); + Data_Get_Struct( self, rb_cipher_t, rb_cipher ); - + ret = cipher_reset( rb_cipher->ctx, iv ); - + if ( ret < 0 ) rb_raise( e_BadInputData, "Either the cipher type, key or initialization vector was not set." ); - + return Qtrue; } /* * call-seq: setkey(key, key_length, operation) @@ -251,11 +251,11 @@ */ VALUE rb_cipher_setkey( VALUE self, VALUE key, VALUE key_length, VALUE operation ) { rb_cipher_t *rb_cipher; int ret; - + Check_Type( key, T_STRING ); Check_Type( key_length, T_FIXNUM ); Check_Type( operation, T_FIXNUM ); Data_Get_Struct( self, rb_cipher_t, rb_cipher ); @@ -277,10 +277,10 @@ VALUE rb_cipher_update( VALUE self, VALUE rb_input ) { rb_cipher_t *rb_cipher; char *input; int ret; - + Check_Type( rb_input, T_STRING ); Data_Get_Struct( self, rb_cipher_t, rb_cipher ); StringValue( rb_input ); \ No newline at end of file