Skip to content

Commit 5888f44

Browse files
committed
decryption success flag
1 parent f56c713 commit 5888f44

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
rb_mumble_protocol (0.1.0)
4+
rb_mumble_protocol (0.1.1)
55

66
GEM
77
remote: https://rubygems.org/

ext/rb_mumble_protocol/src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
use std::cell::RefCell;
22

3-
use magnus::{class, define_module, method, function, prelude::*, Error, RHash};
3+
use magnus::{
4+
class, define_module,
5+
method, function, prelude::*,
6+
Error, RHash,
7+
value::{QTRUE, QFALSE}, Value
8+
};
49

510
use bytes::BytesMut;
611

@@ -66,13 +71,17 @@ impl CryptStateRef {
6671
buffer.to_vec()
6772
}
6873

69-
pub fn decrypt(&self, encrypted: Vec<u8>) -> Vec<u8> {
74+
pub fn decrypt(&self, encrypted: Vec<u8>) -> (Value, Vec<u8>) {
7075
let mut buffer = BytesMut::new();
7176
buffer.extend_from_slice(&encrypted);
7277

73-
self.0.try_borrow_mut().unwrap().decrypt(&mut buffer).unwrap();
78+
let result = self.0.try_borrow_mut().unwrap().decrypt(&mut buffer);
7479

75-
buffer.to_vec()
80+
// TODO: raise error
81+
match result {
82+
Ok(_) => (*QTRUE, buffer.to_vec()),
83+
Err(_) => (*QFALSE, vec![]),
84+
}
7685
}
7786
}
7887

lib/rb_mumble_protocol/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module RbMumbleProtocol
4-
VERSION = "0.1.0"
4+
VERSION = "0.1.1"
55
end

0 commit comments

Comments
 (0)