Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ sudo: false
language: ruby
cache: bundler

os:
- linux
- osx

rvm:
- ruby-head
- 2.6.5
Expand All @@ -15,7 +19,9 @@ gemfile:
- gemfiles/openssl_2_0.gemfile
- gemfiles/openssl_default.gemfile

before_install: gem install bundler -v '~> 2.0'
before_install:
- gem install bundler -v '~> 2.0'
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./script/setup-osx; else sudo ./script/setup-linux; fi

matrix:
fast_finish: true
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in cose.gemspec
gemspec

# TODO: Remove this once libcbor gem is released with
# https://github.com/PJK/libcbor-ruby/pull/10
gem "libcbor", github: "PJK/libcbor-ruby"
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Ruby implementation of RFC [8152](https://tools.ietf.org/html/rfc8152) CBOR Obje
[![Gem](https://img.shields.io/gem/v/cose.svg?style=flat-square)](https://rubygems.org/gems/cose)
[![Travis](https://img.shields.io/travis/cedarcode/cose-ruby.svg?style=flat-square)](https://travis-ci.org/cedarcode/cose-ruby)

## Prerequisites

### OSX

```
brew tap pjk/libcbor
brew install libcbor
```

### Linux (APT)

```
apt-get install libcbor-dev
```

## Installation

Add this line to your application's Gemfile:
Expand Down
2 changes: 1 addition & 1 deletion cose.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 2.3"

spec.add_dependency "cbor", "~> 0.5.9"
spec.add_dependency "libcbor", "~> 0.1.0"

spec.add_development_dependency "appraisal", "~> 2.2.0"
spec.add_development_dependency "bundler", ">= 1.17", "< 3"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/openssl_2_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

source "https://rubygems.org"

gem "libcbor", git: "https://github.com/PJK/libcbor-ruby"
gem "openssl", "~> 2.0.0"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/openssl_2_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

source "https://rubygems.org"

gem "libcbor", git: "https://github.com/PJK/libcbor-ruby"
gem "openssl", "~> 2.1.0"

gemspec path: "../"
2 changes: 2 additions & 0 deletions gemfiles/openssl_default.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

source "https://rubygems.org"

gem "libcbor", git: "https://github.com/PJK/libcbor-ruby"

gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/openssl_head.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

source "https://rubygems.org"

gem "libcbor", git: "https://github.com/PJK/libcbor-ruby"
gem "openssl", git: "https://github.com/ruby/openssl"

gemspec path: "../"
3 changes: 3 additions & 0 deletions lib/cbor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require "libcbor/all"
6 changes: 3 additions & 3 deletions lib/cose/security_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class SecurityMessage
def self.deserialize(cbor)
decoded = CBOR.decode(cbor)

if decoded.is_a?(CBOR::Tagged)
if respond_to?(:tag) && tag != decoded.tag
if decoded.is_a?(CBOR::Tag)
if respond_to?(:tag) && tag != decoded.value
raise(COSE::Error, "Invalid CBOR tag")
end

decoded = decoded.value
decoded = decoded.item
end

from_array(decoded)
Expand Down
10 changes: 10 additions & 0 deletions script/setup-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -x

if ! apt-cache show libcbor-dev >> /dev/null; then
add-apt-repository ppa:yubico/stable -y
apt-get update -q
fi

apt-get install libcbor-dev -y
6 changes: 6 additions & 0 deletions script/setup-osx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -x

brew tap pjk/libcbor
brew install libcbor
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
end

def create_security_message(protected_headers, unprotected_headers, *args, cbor_tag: 0)
CBOR::Tagged.new(cbor_tag, [CBOR.encode(protected_headers), unprotected_headers, *args]).to_cbor
CBOR::Tag.new(cbor_tag, [CBOR.encode(protected_headers), unprotected_headers, *args]).to_cbor
end

def wg_examples(relative_glob)
Expand Down