Module: Autonoma

Defined in:
lib/autonoma.rb,
lib/autonoma/hmac.rb,
lib/autonoma/refs.rb,
lib/autonoma/graph.rb,
lib/autonoma/types.rb,
lib/autonoma/errors.rb,
lib/autonoma/schema.rb,
lib/autonoma/factory.rb,
lib/autonoma/handler.rb,
lib/autonoma/fingerprint.rb,
lib/autonoma/payload_topo.rb

Defined Under Namespace

Modules: Errors, Factory, Fingerprint, Graph, Handler, Hmac, PayloadTopo, Refs, Schema Classes: AuthContext, AutonomaError, CreateOp, FKEdge, FactoryContext, FactoryDefinition, FieldInfo, HandlerConfig, HandlerRequest, HandlerResponse, HookContext, ModelInfo, SchemaInfo, SchemaRelation

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.secure_compare(a, b) ⇒ Object

Constant-time string comparison to prevent timing attacks. Shared by Hmac and Refs modules.



8
9
10
11
12
13
14
15
16
# File 'lib/autonoma/hmac.rb', line 8

def self.secure_compare(a, b)
  return false unless a.bytesize == b.bytesize

  l = a.unpack("C*")
  r = b.unpack("C*")
  result = 0
  l.each_with_index { |v, i| result |= v ^ r[i] }
  result.zero?
end