spec/integration_spec.rb in sjcl-1.0.0 vs spec/integration_spec.rb in sjcl-1.0.1

- old
+ new

@@ -26,6 +26,21 @@ it "should encrypt UTF-8 text" do result = SJCL.encrypt('s33krit', "农历新年 and 農曆新年") puts "sjcl.decrypt('s33krit','#{result}')" # Checking this by hand for now :( end + + it "should fail to decrypt tampered with adata tag" do + json = '{"iv":"+Y+RZjk81MN9wkLVRgfLkA==","v":1,"iter":10000,"ks":256,"ts":64,"mode":"ccm","adata":"Tampered","cipher":"aes","salt":"4TD5tILYe6U=","ct":"NUeGvbXWVEmssnSGORpVSl1OefdLHjU2yPZnxVsPifyD1TJ3+w=="}' + expect { + SJCL.decrypt('s33krit', json) + }.to raise_error SJCL::Mode::CCM::TagAuthError + end + + it "should fail to decrypt tampered with crypts" do + json = '{"iv":"+Y+RZjk81MN9wkLVRgfLkA==","v":1,"iter":10000,"ks":256,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"4TD5tILYe6U=","ct":"NUeGvbXWVEmssnSGORpVSl1OefdLHjU2yPZnxVsPifyD1tJ3+w=="}' + expect { + SJCL.decrypt('s33krit', json) + }.to raise_error SJCL::Mode::CCM::TagAuthError + end + end