Ruby로 구현한 JOSE(Javascript Object Signing and Encryption) - RFC 7516, RFC 7515 규격입니다. JOSE 규격은 SyrupPay 결제 데이터 암복호화 및 AccessToken 발행 등에 사용되며 SyrupPay 서비스의 가맹점에 배포하기 위한 목적으로 라이브러리가 구현되었습니다.
~>= Ruby 2.0.0
$ geminstallsyruppay_joserequire'syruppay_jose'# SyrupPay가 발급하는 secretkey='12345678901234561234567890123456'# JWE header 규격# alg : key wrap encryption algorithm. 아래 Supported JOSE encryption algorithms 참조# enc : content encryption algorithm. 아래 Supported JOSE encryption algorithms 참조# kid : SyrupPay가 발급하는 issheader={:alg=>'A256KW',:enc=>'A128CBC-HS256',:kid=>'syruppay_sample'}# 암호화 할 데이터payload='{"iss":"syruppap_sample", "exp":1300819380, "isSample":true}'# encryption and serializejwe_token=SyrupPay::JsonEncryptionCompactSerialization.serialization(key,header,payload)# decryption and deserializeactual=SyrupPay::CompactDeserialization.deserialization(key,jwe_token)require'syruppay_jose'# SyrupPay가 발급하는 secretkey='12345678901234561234567890123456'# JWS header 규격# alg : signature algorithm. 아래 Supported JOSE encryption algorithms 참조# kid : SyrupPay가 발급하는 issheader={:alg=>'HS256',:kid=>'syruppay_sample'}# sign 할 데이터claims='{"iss":"syruppap_sample", "exp":1300819380, "isSample":true}'# # sign and serializejws_value=SyrupPay::JsonSignatureCompactSerialization.serialization(key,header,claims)# verify and deserializeactual=SyrupPay::CompactDeserialization.deserialization(key,jws_value)| 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 Param Value | Content Encryption Algorithm |
|---|---|
| A128CBC-HS256 | AES_128_CBC_HMAC_SHA_256 authenticated encryption algorithm |
| alg Param Value | Digital Signature or MAC Algorithm |
|---|---|
| HS256 | HMAC using SHA-256 |
The gem is available as open source under the terms of the MIT License.