mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ruby.h (struct RString): embed small strings.
(RSTRING_LEN): defined for accessing string members. (RSTRING_PTR): ditto. * string.c: use RSTRING_LEN and RSTRING_PTR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									22f249ebd7
								
							
						
					
					
						commit
						25c50cd193
					
				
					 43 changed files with 484 additions and 512 deletions
				
			
		| 
						 | 
				
			
			@ -68,7 +68,7 @@ ossl_pkey_new_from_file(VALUE filename)
 | 
			
		|||
    EVP_PKEY *pkey;
 | 
			
		||||
 | 
			
		||||
    SafeStringValue(filename);
 | 
			
		||||
    if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
 | 
			
		||||
    if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
 | 
			
		||||
	ossl_raise(ePKeyError, "%s", strerror(errno));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -169,13 +169,12 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
 | 
			
		|||
    GetPKey(self, pkey);
 | 
			
		||||
    EVP_SignInit(&ctx, GetDigestPtr(digest));
 | 
			
		||||
    StringValue(data);
 | 
			
		||||
    EVP_SignUpdate(&ctx, RSTRING(data)->ptr, RSTRING(data)->len);
 | 
			
		||||
    EVP_SignUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
 | 
			
		||||
    str = rb_str_new(0, EVP_PKEY_size(pkey)+16);
 | 
			
		||||
    if (!EVP_SignFinal(&ctx, RSTRING(str)->ptr, &buf_len, pkey))
 | 
			
		||||
    if (!EVP_SignFinal(&ctx, RSTRING_PTR(str), &buf_len, pkey))
 | 
			
		||||
	ossl_raise(ePKeyError, NULL);
 | 
			
		||||
    assert(buf_len <= RSTRING(str)->len);
 | 
			
		||||
    RSTRING(str)->len = buf_len;
 | 
			
		||||
    RSTRING(str)->ptr[buf_len] = 0;
 | 
			
		||||
    assert(buf_len <= RSTRING_LEN(str));
 | 
			
		||||
    rb_str_set_len(str, buf_len);
 | 
			
		||||
 | 
			
		||||
    return str;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -190,8 +189,8 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
 | 
			
		|||
    EVP_VerifyInit(&ctx, GetDigestPtr(digest));
 | 
			
		||||
    StringValue(sig);
 | 
			
		||||
    StringValue(data);
 | 
			
		||||
    EVP_VerifyUpdate(&ctx, RSTRING(data)->ptr, RSTRING(data)->len);
 | 
			
		||||
    switch (EVP_VerifyFinal(&ctx, RSTRING(sig)->ptr, RSTRING(sig)->len, pkey)) {
 | 
			
		||||
    EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
 | 
			
		||||
    switch (EVP_VerifyFinal(&ctx, RSTRING_PTR(sig), RSTRING_LEN(sig), pkey)) {
 | 
			
		||||
    case 0:
 | 
			
		||||
	return Qfalse;
 | 
			
		||||
    case 1:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue