Module: JOSE::JWA::Curve25519

Extended by:
Curve25519
Included in:
Curve25519
Defined in:
lib/jose/jwa/curve25519.rb

Constant Summary collapse

MUTEX =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#__config_change__(lock = true) ⇒ Object



30
31
32
33
34
35
# File 'lib/jose/jwa/curve25519.rb', line 30

def __config_change__(lock = true)
  MUTEX.lock if lock
  @__implementation__ ||= nil
  @__implementation__ = __pick_best_implementation__ if @__implementation__.nil? or @__implementation__.__ruby__? or not @__implementation__.__supported__?
  MUTEX.unlock if lock
end

#__implementation__Object



10
11
12
# File 'lib/jose/jwa/curve25519.rb', line 10

def __implementation__
  return MUTEX.synchronize { @__implementation__ ||= __pick_best_implementation__ }
end

#__implementation__=(implementation) ⇒ Object



14
15
16
# File 'lib/jose/jwa/curve25519.rb', line 14

def __implementation__=(implementation)
  return MUTEX.synchronize { @__implementation__ = implementation }
end

#__register__(implementation, ruby = false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jose/jwa/curve25519.rb', line 18

def __register__(implementation, ruby = false)
  MUTEX.synchronize {
    if ruby
      @__ruby_implementations__.unshift(implementation)
    else
      @__implementations__.unshift(implementation)
    end
    __config_change__(false)
    implementation
  }
end

#ed25519_keypair(secret = nil) ⇒ Object



37
38
39
# File 'lib/jose/jwa/curve25519.rb', line 37

def ed25519_keypair(secret = nil)
  return (@__implementation__ || __implementation__).ed25519_keypair(secret)
end

#ed25519_secret_to_public(sk) ⇒ Object



41
42
43
# File 'lib/jose/jwa/curve25519.rb', line 41

def ed25519_secret_to_public(sk)
  return (@__implementation__ || __implementation__).ed25519_secret_to_public(sk)
end

#ed25519_sign(m, sk) ⇒ Object



45
46
47
# File 'lib/jose/jwa/curve25519.rb', line 45

def ed25519_sign(m, sk)
  return (@__implementation__ || __implementation__).ed25519_sign(m, sk)
end

#ed25519_verify(sig, m, pk) ⇒ Object



49
50
51
# File 'lib/jose/jwa/curve25519.rb', line 49

def ed25519_verify(sig, m, pk)
  return (@__implementation__ || __implementation__).ed25519_verify(sig, m, pk)
end

#ed25519ph_keypair(secret = nil) ⇒ Object



53
54
55
# File 'lib/jose/jwa/curve25519.rb', line 53

def ed25519ph_keypair(secret = nil)
  return (@__implementation__ || __implementation__).ed25519ph_keypair(secret)
end

#ed25519ph_secret_to_public(sk) ⇒ Object



57
58
59
# File 'lib/jose/jwa/curve25519.rb', line 57

def ed25519ph_secret_to_public(sk)
  return (@__implementation__ || __implementation__).ed25519ph_secret_to_public(sk)
end

#ed25519ph_sign(m, sk) ⇒ Object



61
62
63
# File 'lib/jose/jwa/curve25519.rb', line 61

def ed25519ph_sign(m, sk)
  return (@__implementation__ || __implementation__).ed25519ph_sign(m, sk)
end

#ed25519ph_verify(sig, m, pk) ⇒ Object



65
66
67
# File 'lib/jose/jwa/curve25519.rb', line 65

def ed25519ph_verify(sig, m, pk)
  return (@__implementation__ || __implementation__).ed25519ph_verify(sig, m, pk)
end

#x25519_keypair(secret = nil) ⇒ Object



69
70
71
# File 'lib/jose/jwa/curve25519.rb', line 69

def x25519_keypair(secret = nil)
  return (@__implementation__ || __implementation__).x25519_keypair(secret)
end

#x25519_secret_to_public(sk) ⇒ Object



73
74
75
# File 'lib/jose/jwa/curve25519.rb', line 73

def x25519_secret_to_public(sk)
  return (@__implementation__ || __implementation__).x25519_secret_to_public(sk)
end

#x25519_shared_secret(pk, sk) ⇒ Object



77
78
79
# File 'lib/jose/jwa/curve25519.rb', line 77

def x25519_shared_secret(pk, sk)
  return (@__implementation__ || __implementation__).x25519_shared_secret(pk, sk)
end