Skip to content

Commit ef51254

Browse files
committed
TeamCity: Add maximum message size for string
1 parent 7c1692c commit ef51254

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/rex/proto/teamcity/rsa.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,22 @@ def self.rsa_encrypt(modulus, exponent, text)
4949
h.length.odd? ? h.prepend('0') : h
5050
end
5151

52+
def self.two_byte_chars?(str)
53+
str.bytesize > str.length
54+
end
55+
56+
def self.max_data_size(str)
57+
# Taken from TeamCity's login page JavaScript sources.
58+
two_byte_chars?(str) ? 58 : 116
59+
end
60+
5261
# @param [String] text The text to encrypt.
5362
# @param [String] public_key The hex representation of the public key to use.
5463
# @return [String] A string blob.
5564
def self.encrypt_data(text, public_key)
5665
exponent = '10001'
5766
e = []
58-
g = 116 # TODO: wire up d.maxDataSize(f)
67+
g = max_data_size(text)
5968

6069
c = 0
6170
while c < text.length

0 commit comments

Comments
 (0)