Skip to content

Commit

Permalink
Merge branch 'master' of github.com:danielberkompas/ex_twilio
Browse files Browse the repository at this point in the history
  • Loading branch information
danielberkompas committed Jun 5, 2021
2 parents 7a404de + 9bdaff6 commit 8842634
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: v1.0
name: CI Build
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
auto_cancel:
running:
when: 'true'
fail_fast:
stop:
when: 'true'
blocks:
- name: Build
dependencies: []
task:
env_vars:
- name: MIX_ENV
value: test
secrets:
- name: ex-twilio-env
jobs:
- name: Build
matrix:
- env_var: ELIXIR_VERSION
values:
- 1.11.3
commands:
- sem-version elixir $ELIXIR_VERSION
- checkout
- cache restore
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
- bin/test
- cache store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ExTwilio
========
[![Hex.pm](https://img.shields.io/hexpm/v/ex_twilio.svg)](https://hex.pm/packages/ex_twilio)
[![Build Status](https://travis-ci.org/danielberkompas/ex_twilio.svg?branch=master)](https://travis-ci.org/danielberkompas/ex_twilio)
[![Build Status](https://danielberkompas.semaphoreci.com/badges/ex_twilio/branches/master.svg?style=shields)](https://danielberkompas.semaphoreci.com/projects/ex_twilio)
[![Inline docs](http://inch-ci.org/github/danielberkompas/ex_twilio.svg?branch=master)](http://inch-ci.org/github/danielberkompas/ex_twilio)
[![Deps Status](https://beta.hexfaktor.org/badge/all/github/danielberkompas/ex_twilio.svg)](https://beta.hexfaktor.org/github/danielberkompas/ex_twilio)

Expand Down
11 changes: 9 additions & 2 deletions lib/ex_twilio/request_validator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ defmodule ExTwilio.RequestValidator do
|> Enum.join()
end

defp compute_hmac(data, key), do: :crypto.hmac(:sha, key, data)
defp compute_hmac(data, key), do: hmac(:sha, key, data)

# TODO: remove when we require OTP 22
if System.otp_release() >= "22" do
defp hmac(digest, key, data), do: :crypto.mac(:hmac, digest, key, data)
else
defp hmac(digest, key, data), do: :crypto.hmac(digest, key, data)
end

# Implementation taken from Plug.Crypto
# https://github.com/elixir-plug/plug/blob/master/lib/plug/crypto.ex
Expand All @@ -48,7 +55,7 @@ defmodule ExTwilio.RequestValidator do
end

defp secure_compare(<<x, left::binary>>, <<y, right::binary>>, acc) do
xorred = x ^^^ y
xorred = bxor(x, y)
secure_compare(left, right, acc ||| xorred)
end

Expand Down

0 comments on commit 8842634

Please sign in to comment.