0.0
No commit activity in last 3 years
No release in over 3 years
Library for SyrupPay service's merchant. This is implemented JOSE specification, RFC 7515, 7516. support algorithm : JWE-A128KW, A256KW, A128CBC-HS256, JWS-HS256
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
~> 3.3

Runtime

 Project Readme

JOSE for SyrupPay

Ruby로 구현한 JOSE(Javascript Object Signing and Encryption) - RFC 7516, RFC 7515 규격입니다. JOSE 규격은 SyrupPay 결제 데이터 암복호화 및 AccessToken 발행 등에 사용되며 SyrupPay 서비스의 가맹점에 배포하기 위한 목적으로 라이브러리가 구현되었습니다.

Supported Ruby version

~>= Ruby 2.0.0

Installation

$ gem install syruppay_jose

Usage

JWE

require 'syruppay_jose'

# SyrupPay가 발급하는 secret
key = '12345678901234561234567890123456'
# JWE header 규격
# alg : key wrap encryption algorithm. 아래 Supported JOSE encryption algorithms 참조
# enc : content encryption algorithm. 아래 Supported JOSE encryption algorithms 참조
# kid : SyrupPay가 발급하는 iss
header = {:alg=>'A256KW', :enc=>'A128CBC-HS256', :kid=>'syruppay_sample'}
# 암호화 할 데이터
payload = '{"iss":"syruppap_sample", "exp":1300819380, "isSample":true}'

# encryption and serialize
jwe_token = SyrupPay::JsonEncryptionCompactSerialization.serialization(key, header, payload)

# decryption and deserialize
actual = SyrupPay::CompactDeserialization.deserialization(key, jwe_token)

JWS

require 'syruppay_jose'

# SyrupPay가 발급하는 secret
key = '12345678901234561234567890123456'
# JWS header 규격
# alg : signature algorithm. 아래 Supported JOSE encryption algorithms 참조
# kid : SyrupPay가 발급하는 iss
header = {:alg=>'HS256', :kid=>'syruppay_sample'}
# sign 할 데이터
claims = '{"iss":"syruppap_sample", "exp":1300819380, "isSample":true}' # 

# sign and serialize
jws_value = SyrupPay::JsonSignatureCompactSerialization.serialization(key, header, claims)

# verify and deserialize
actual = SyrupPay::CompactDeserialization.deserialization(key, jws_value)

Supported JOSE encryption algorithms

"alg" (Algorithm) Header Parameter Values For JWE

alg Param Value Key Management Algorithm
A128KW AES Key Wrap with default initial value using 128 bit key
A256KW AES Key Wrap with default initial value using 256 bit key

"enc" (Encryption Algorithm) Header Parameter Values for JWE

enc Param Value Content Encryption Algorithm
A128CBC-HS256 AES_128_CBC_HMAC_SHA_256 authenticated encryption algorithm

"alg" (Algorithm) Header Parameter Values for JWS

alg Param Value Digital Signature or MAC Algorithm
HS256 HMAC using SHA-256

License

The gem is available as open source under the terms of the MIT License.