Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3b196f5eda3a
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 854cdcecc734
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 2, 2017

  1. Fix: OpenSSL 1.1.0 renamed some symbols

    - sk_free => OPENSSL_sk_free
    - sk_num => OPENSSL_sk_num
    - sk_pop_free => OPENSSL_sk_pop_free
    - sk_value => OPENSSL_sk_value
    - evp_md_ctx_create => evp_md_ctx_new
    - evp_md_ctx_destroy => evp_md_ctx_free
    ysbaddaden committed Apr 2, 2017
    Copy the full SHA
    b67a118 View commit details

Commits on Apr 3, 2017

  1. Copy the full SHA
    58b8481 View commit details
  2. Merge pull request #4230 from ysbaddaden/std-fix-openssl-110

    Fix: OpenSSL 1.1.0
    ysbaddaden authored Apr 3, 2017
    Copy the full SHA
    854cdce View commit details
Showing with 25 additions and 18 deletions.
  1. +0 −2 spec/std/openssl/hmac_spec.cr
  2. +6 −6 src/openssl/digest/digest.cr
  3. +0 −2 src/openssl/hmac.cr
  4. +19 −8 src/openssl/lib_crypto.cr
2 changes: 0 additions & 2 deletions spec/std/openssl/hmac_spec.cr
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ require "openssl/hmac"

describe OpenSSL::HMAC do
[
{:dss, "46b4ec586117154dacd49d664e5d63fdc88efb51"},
{:dss1, "46b4ec586117154dacd49d664e5d63fdc88efb51"},
{:md4, "f3593b56f00b25c8af31d02ddef6d2d0"},
{:md5, "0c7a250281315ab863549f66cd8a3a53"},
{:sha1, "46b4ec586117154dacd49d664e5d63fdc88efb51"},
12 changes: 6 additions & 6 deletions src/openssl/digest/digest.cr
Original file line number Diff line number Diff line change
@@ -15,12 +15,12 @@ module OpenSSL
raise Error.new("Invalid EVP_MD_CTX") unless @ctx
end

protected def self.create_evp_mt_ctx(name)
protected def self.new_evp_mt_ctx(name)
md = LibCrypto.evp_get_digestbyname(name)
unless md
raise UnsupportedError.new("Unsupported digest algorithm: #{name}")
end
ctx = LibCrypto.evp_md_ctx_create
ctx = LibCrypto.evp_md_ctx_new
unless ctx
raise Error.new "Digest initialization failed."
end
@@ -31,17 +31,17 @@ module OpenSSL
end

def self.new(name)
new(name, create_evp_mt_ctx(name))
new(name, new_evp_mt_ctx(name))
end

def finalize
LibCrypto.evp_md_ctx_destroy(self)
LibCrypto.evp_md_ctx_free(self)
end

def clone
ctx = LibCrypto.evp_md_ctx_create
ctx = LibCrypto.evp_md_ctx_new
if LibCrypto.evp_md_ctx_copy(ctx, @ctx) == 0
LibCrypto.evp_md_ctx_destroy(ctx)
LibCrypto.evp_md_ctx_free(ctx)
raise Error.new("Unable to clone digest")
end
Digest.new(@name, ctx)
2 changes: 0 additions & 2 deletions src/openssl/hmac.cr
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ require "./lib_crypto"
class OpenSSL::HMAC
def self.digest(algorithm : Symbol, key, data) : Bytes
evp = case algorithm
when :dss then LibCrypto.evp_dss
when :dss1 then LibCrypto.evp_dss1
when :md4 then LibCrypto.evp_md4
when :md5 then LibCrypto.evp_md5
when :ripemd160 then LibCrypto.evp_ripemd160
27 changes: 19 additions & 8 deletions src/openssl/lib_crypto.cr
Original file line number Diff line number Diff line change
@@ -74,8 +74,6 @@ lib LibCrypto

type EVP_MD = Void*

fun evp_dss = EVP_dss : EVP_MD
fun evp_dss1 = EVP_dss1 : EVP_MD
fun evp_md4 = EVP_md4 : EVP_MD
fun evp_md5 = EVP_md5 : EVP_MD
fun evp_ripemd160 = EVP_ripemd160 : EVP_MD
@@ -132,16 +130,22 @@ lib LibCrypto
fun hmac_ctx_copy = HMAC_CTX_copy(dst : HMAC_CTX, src : HMAC_CTX) : Int32

fun evp_get_digestbyname = EVP_get_digestbyname(name : UInt8*) : EVP_MD
fun evp_md_ctx_create = EVP_MD_CTX_create : EVP_MD_CTX
fun evp_digestinit_ex = EVP_DigestInit_ex(ctx : EVP_MD_CTX, type : EVP_MD, engine : Void*) : Int32
fun evp_digestupdate = EVP_DigestUpdate(ctx : EVP_MD_CTX, data : UInt8*, count : LibC::SizeT) : Int32
fun evp_md_ctx_destroy = EVP_MD_CTX_destroy(ctx : EVP_MD_CTX)
fun evp_md_ctx_copy = EVP_MD_CTX_copy(dst : EVP_MD_CTX, src : EVP_MD_CTX) : Int32
fun evp_md_ctx_md = EVP_MD_CTX_md(ctx : EVP_MD_CTX) : EVP_MD
fun evp_md_size = EVP_MD_size(md : EVP_MD) : Int32
fun evp_md_block_size = EVP_MD_block_size(md : EVP_MD) : LibC::Int
fun evp_digestfinal_ex = EVP_DigestFinal_ex(ctx : EVP_MD_CTX, md : UInt8*, size : UInt32*) : Int32

{% if OPENSSL_110 %}
fun evp_md_ctx_new = EVP_MD_CTX_new : EVP_MD_CTX
fun evp_md_ctx_free = EVP_MD_CTX_free(ctx : EVP_MD_CTX)
{% else %}
fun evp_md_ctx_new = EVP_MD_CTX_create : EVP_MD_CTX
fun evp_md_ctx_free = EVP_MD_CTX_destroy(ctx : EVP_MD_CTX)
{% end %}

fun evp_get_cipherbyname = EVP_get_cipherbyname(name : UInt8*) : EVP_CIPHER
fun evp_cipher_name = EVP_CIPHER_name(cipher : EVP_CIPHER) : UInt8*
fun evp_cipher_nid = EVP_CIPHER_nid(cipher : EVP_CIPHER) : Int32
@@ -202,10 +206,17 @@ lib LibCrypto
NID_commonName = 13
NID_subject_alt_name = 85

fun sk_free(st : Void*)
fun sk_num = sk_num(x0 : Void*) : Int
fun sk_pop_free(st : Void*, callback : (Void*) ->)
fun sk_value = sk_value(x0 : Void*, x1 : Int) : Void*
{% if OPENSSL_110 %}
fun sk_free = OPENSSL_sk_free(st : Void*)
fun sk_num = OPENSSL_sk_num(x0 : Void*) : Int
fun sk_pop_free = OPENSSL_sk_pop_free(st : Void*, callback : (Void*) ->)
fun sk_value = OPENSSL_sk_value(x0 : Void*, x1 : Int) : Void*
{% else %}
fun sk_free(st : Void*)
fun sk_num(x0 : Void*) : Int
fun sk_pop_free(st : Void*, callback : (Void*) ->)
fun sk_value(x0 : Void*, x1 : Int) : Void*
{% end %}

fun x509_dup = X509_dup(a : X509) : X509
fun x509_free = X509_free(a : X509)