Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matrix-org
Olm
Commits
4be7cc36
Commit
4be7cc36
authored
Feb 19, 2021
by
manuroe
Browse files
OLMKit: Forgot to implement pickle v2 for OLMSession
parent
b69b56d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
xcode/OLMKit/OLMSession.m
View file @
4be7cc36
...
...
@@ -21,6 +21,7 @@
#import "OLMAccount_Private.h"
#import "OLMSession_Private.h"
#include "olm/olm.h"
#import "OLMKit.h"
@implementation
OLMSession
...
...
@@ -359,6 +360,13 @@
self
=
[
self
initWithSerializedData
:
pickle
key
:
key
error
:&
error
];
}
else
if
([
version
isEqualToString
:
@"2"
])
{
NSString
*
pickle
=
[
decoder
decodeObjectOfClass
:[
NSString
class
]
forKey
:
@"pickle"
];
NSData
*
key
=
OLMKit
.
sharedInstance
.
pickleKeyDelegate
.
pickleKey
;
NSParameterAssert
(
key
);
self
=
[
self
initWithSerializedData
:
pickle
key
:
key
error
:&
error
];
}
NSParameterAssert
(
error
==
nil
);
NSParameterAssert
(
self
!=
nil
);
...
...
@@ -370,14 +378,23 @@
}
-
(
void
)
encodeWithCoder
:(
NSCoder
*
)
encoder
{
NSData
*
key
=
[
OLMUtility
randomBytesOfLength
:
32
];
NSData
*
key
=
OLMKit
.
sharedInstance
.
pickleKeyDelegate
.
pickleKey
;
if
(
key
)
{
[
encoder
encodeObject
:
@"2"
forKey
:
@"version"
];
}
else
{
key
=
[
OLMUtility
randomBytesOfLength
:
32
];
[
encoder
encodeObject
:
key
forKey
:
@"key"
];
[
encoder
encodeObject
:
@"1"
forKey
:
@"version"
];
}
NSError
*
error
=
nil
;
NSString
*
pickle
=
[
self
serializeDataWithKey
:
key
error
:
&
error
];
NSParameterAssert
(
pickle
.
length
>
0
&&
error
==
nil
);
[
encoder
encodeObject
:
pickle
forKey
:
@"pickle"
];
[
encoder
encodeObject
:
key
forKey
:
@"key"
];
[
encoder
encodeObject
:
@"1"
forKey
:
@"version"
];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment