Skip to content

Commit

Permalink
updating compress and uncompress methods to follow the RFC 1951 stand…
Browse files Browse the repository at this point in the history
…ard,

from what I can tell, ZLib wraps the data (RFC 1950 around RFC 1951) making
it incompatible with other libraries
https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-10#section-4.1.4
http://stackoverflow.com/questions/15632979/java-decompressing-array-of-bytes
  • Loading branch information
Amy Madden authored and Amy Madden committed Jul 7, 2016
1 parent 9388a4a commit a356994
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/jose/jwe/zip_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ def to_map(fields)
# JOSE::JWE::ZIP callbacks

def compress(plain_text)
return Zlib.deflate(plain_text)
zstream = Zlib::Deflate.new(nil, -Zlib::MAX_WBITS)
buf = zstream.deflate(plain_text, Zlib::FINISH)
zstream.finish
zstream.close
return buf
end

def uncompress(cipher_text)
return Zlib.inflate(cipher_text)
zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS)
buf = zstream.inflate(cipher_text)
zstream.finish
zstream.close
return buf
end

end

0 comments on commit a356994

Please sign in to comment.