Ejemplo n.º 1
0
static CFDataRef rb_create_cf_data(VALUE string){
  StringValue(string);
  if(rb_enc_get_index(rb_obj_encoding(string))== rb_ascii8bit_encindex()){
    return CFDataCreate(NULL, (UInt8*)RSTRING_PTR(string), RSTRING_LEN(string));
  }
  else{
    string = rb_str_export_to_enc(string, rb_utf8_encoding());
    return CFDataCreate(NULL, (UInt8*)RSTRING_PTR(string), RSTRING_LEN(string));
  }
}
Ejemplo n.º 2
0
static VALUE rb_create_keychain(int argc, VALUE *argv, VALUE self){
  VALUE password, path;
  rb_scan_args(argc, argv, "11", &path, &password);

  char * c_password = NULL;
  UInt32 passwordLength = 0;
  if(!NIL_P(password)){
    password = rb_str_conv_enc(password, (rb_encoding*)rb_obj_encoding(password), rb_utf8_encoding());
    c_password = StringValueCStr(password);
    passwordLength = (UInt32)strlen(c_password);
  }

  SecKeychainRef keychain;
  OSStatus result =SecKeychainCreate(StringValueCStr(path), passwordLength, c_password, c_password == NULL, NULL, &keychain);
  CheckOSStatusOrRaise(result);

  return KeychainFromSecKeychainRef(keychain);

}
Ejemplo n.º 3
0
static VALUE encoding_spec_rb_obj_encoding(VALUE self, VALUE obj) {
    return rb_obj_encoding(obj);
}