| 5 |
| #include <string> |
| 6 | #include <collection.h> |
| 7 | #include "CXWrapper.h" |
| 8 | #include <wrl.h> |
| 9 | #include <robuffer.h> |
| 10 |
| 11 | using namespace Windows::Storage::Streams; |
| 12 | using namespace Microsoft::WRL; |
| 13 | using namespace libtgvoip; |
| 14 | using namespace Platform; |
| 15 | using namespace tgvoip; |
| 16 | using namespace Windows::Security::Cryptography; |
| 17 | using namespace Windows::Security::Cryptography::Core; |
| 18 | using namespace Windows::Storage::Streams; |
| 19 | using namespace Windows::Data::Json; |
| 20 | using namespace Windows::Phone::Media::Devices; |
| 21 |
| 22 | //CryptographicHash^ MicrosoftCryptoImpl::sha1Hash; |
| 23 | //CryptographicHash^ MicrosoftCryptoImpl::sha256Hash; |
| 24 | HashAlgorithmProvider^ MicrosoftCryptoImpl::sha1Provider; |
| 25 | HashAlgorithmProvider^ MicrosoftCryptoImpl::sha256Provider; |
| 26 | SymmetricKeyAlgorithmProvider^ MicrosoftCryptoImpl::aesKeyProvider; |
| 27 |
| 28 | /*struct tgvoip_cx_data{ |
| 29 | VoIPControllerWrapper^ self; |
| 30 | };*/ |
| 31 |
| 32 | VoIPControllerWrapper::VoIPControllerWrapper(){ |
| 33 | VoIPController::crypto.aes_ige_decrypt=MicrosoftCryptoImpl::AesIgeDecrypt; |
| 34 | VoIPController::crypto.aes_ige_encrypt=MicrosoftCryptoImpl::AesIgeEncrypt; |
| 35 | VoIPController::crypto.aes_ctr_encrypt = MicrosoftCryptoImpl::AesCtrEncrypt; |
| 36 | VoIPController::crypto.sha1=MicrosoftCryptoImpl::SHA1; |
| 37 | VoIPController::crypto.sha256=MicrosoftCryptoImpl::SHA256; |
| 38 | VoIPController::crypto.rand_bytes=MicrosoftCryptoImpl::RandBytes; |
| 39 | MicrosoftCryptoImpl::Init(); |
| 40 | controller=new VoIPController(); |
| 41 | controller->implData=(void*)this; |
| 42 | VoIPController::Callbacks callbacks={0}; |
| 43 | callbacks.connectionStateChanged=VoIPControllerWrapper::OnStateChanged; |
| 44 | callbacks.signalBarCountChanged=VoIPControllerWrapper::OnSignalBarsChanged; |
| 45 | controller->SetCallbacks(callbacks); |
| 46 | } |
| 47 |
| 48 | VoIPControllerWrapper::~VoIPControllerWrapper(){ |
| 49 | controller->Stop(); |
| 50 | delete controller; |
| 51 | } |
| 52 |
| 53 | void VoIPControllerWrapper::Start(){ |
| 54 | controller->Start(); |
| 55 | } |
| 56 |
| 57 | void VoIPControllerWrapper::Connect(){ |
| 58 | controller->Connect(); |
| 59 | } |
| 60 |
| 61 | void VoIPControllerWrapper::SetPublicEndpoints(const Platform::Array<libtgvoip::Endpoint^>^ endpoints, bool allowP2P, int32_t connectionMaxLayer){ |
| 62 | std::vector<tgvoip::Endpoint> eps; |
| 63 | for (unsigned int i = 0; i < endpoints->Length; i++) |
| 64 | { |
| 65 | libtgvoip::Endpoint^ _ep = endpoints[i]; |
| 66 | tgvoip::Endpoint ep; |
| 67 | ep.id = _ep->id; |
| 68 | ep.type = tgvoip::Endpoint::Type::UDP_RELAY; |
| 69 | char buf[128]; |
| 70 | if (_ep->ipv4){ |
| 71 | WideCharToMultiByte(CP_UTF8, 0, _ep->ipv4->Data(), -1, buf, sizeof(buf), NULL, NULL); |
| 72 | ep.address = IPv4Address(buf); |
| 73 | } |
| 74 | if (_ep->ipv6){ |
| 75 | WideCharToMultiByte(CP_UTF8, 0, _ep->ipv6->Data(), -1, buf, sizeof(buf), NULL, NULL); |
| 76 | ep.v6address = IPv6Address(buf); |
| 77 | } |
| 78 | ep.port = _ep->port; |
| 79 | if (_ep->peerTag->Length != 16) |
| 80 | throw ref new Platform::InvalidArgumentException("Peer tag must be exactly 16 bytes long"); |
| 81 | memcpy(ep.peerTag, _ep->peerTag->Data, 16); |
| 82 | eps.push_back(ep); |
| 83 | } |
| 84 | controller->SetRemoteEndpoints(eps, allowP2P, connectionMaxLayer); |
| 85 | } |
| 86 |
| 87 | void VoIPControllerWrapper::SetNetworkType(NetworkType type){ |
| 88 | controller->SetNetworkType((int)type); |
| 89 | } |
| 90 |
| 91 | void VoIPControllerWrapper::SetMicMute(bool mute){ |
| 92 | controller->SetMicMute(mute); |
| 93 | } |
| 94 |
| 95 | int64 VoIPControllerWrapper::GetPreferredRelayID(){ |
| 96 | return controller->GetPreferredRelayID(); |
| 97 | } |
| 98 |
| 99 | int32_t VoIPControllerWrapper::GetConnectionMaxLayer(){ |
| 100 | return tgvoip::VoIPController::GetConnectionMaxLayer(); |
| 101 | } |
| 102 |
| 103 | void VoIPControllerWrapper::SetEncryptionKey(const Platform::Array<uint8>^ key, bool isOutgoing){ |
| 104 | if(key->Length!=256) |
| 105 | throw ref new Platform::InvalidArgumentException("Encryption key must be exactly 256 bytes long"); |
| 106 | controller->SetEncryptionKey((char*)key->Data, isOutgoing); |
| 107 | } |
| 108 |
| 109 | int VoIPControllerWrapper::GetSignalBarsCount(){ |
| 110 | return controller->GetSignalBarsCount(); |
| 111 | } |
| 112 |
| 113 | CallState VoIPControllerWrapper::GetConnectionState(){ |
| 114 | return (CallState)controller->GetConnectionState(); |
| 115 | } |
| 116 |
| 117 | TrafficStats^ VoIPControllerWrapper::GetStats(){ |
| 118 | tgvoip::VoIPController::TrafficStats _stats; |
| 119 | controller->GetStats(&_stats); |
| 120 |
| 121 | TrafficStats^ stats = ref new TrafficStats(); |
| 122 | stats->bytesSentWifi = _stats.bytesSentWifi; |
| 123 | stats->bytesSentMobile = _stats.bytesSentMobile; |
| 124 | stats->bytesRecvdWifi = _stats.bytesRecvdWifi; |
| 125 | stats->bytesRecvdMobile = _stats.bytesRecvdMobile; |
| 126 |
| 127 | return stats; |
| 128 | } |
| 129 |
| 130 | Platform::String^ VoIPControllerWrapper::GetDebugString(){ |
| 131 | std::string log = controller->GetDebugString(); |
| 132 | size_t len = sizeof(wchar_t)*(log.length() + 1); |
| 133 | wchar_t* wlog = (wchar_t*)malloc(len); |
| 134 | MultiByteToWideChar(CP_UTF8, 0, log.c_str(), -1, wlog, len / sizeof(wchar_t)); |
| 135 | Platform::String^ res = ref new Platform::String(wlog); |
| 136 | free(wlog); |
| 137 | return res; |
| 138 | } |
| 139 |
| 140 | Platform::String^ VoIPControllerWrapper::GetDebugLog(){ |
| 141 | std::string log=controller->GetDebugLog(); |
| 142 | size_t len=sizeof(wchar_t)*(log.length()+1); |
| 143 | wchar_t* wlog=(wchar_t*)malloc(len); |
| 144 | MultiByteToWideChar(CP_UTF8, 0, log.c_str(), -1, wlog, len/sizeof(wchar_t)); |
| 145 | Platform::String^ res=ref new Platform::String(wlog); |
| 146 | free(wlog); |
| 147 | return res; |
| 148 | } |
| 149 |
| 150 | Error VoIPControllerWrapper::GetLastError(){ |
| 151 | return (Error)controller->GetLastError(); |
| 152 | } |
| 153 |
| 154 | Platform::String^ VoIPControllerWrapper::GetVersion(){ |
| 155 | const char* v=VoIPController::GetVersion(); |
| 156 | wchar_t buf[32]; |
| 157 | MultiByteToWideChar(CP_UTF8, 0, v, -1, buf, sizeof(buf)); |
| 158 | return ref new Platform::String(buf); |
| 159 | } |
| 160 |
| 161 | void VoIPControllerWrapper::OnStateChanged(VoIPController* c, int state){ |
| 162 | reinterpret_cast<VoIPControllerWrapper^>(c->implData)->OnStateChangedInternal(state); |
| 163 | } |
| 164 |
| 165 | void VoIPControllerWrapper::OnSignalBarsChanged(VoIPController* c, int count){ |
| 166 | reinterpret_cast<VoIPControllerWrapper^>(c->implData)->OnSignalBarsChangedInternal(count); |
| 167 | } |
| 168 |
| 169 | void VoIPControllerWrapper::OnStateChangedInternal(int state){ |
| 170 | CallStateChanged(this, (CallState)state); |
| 171 | } |
| 172 |
| 173 | void VoIPControllerWrapper::OnSignalBarsChangedInternal(int count){ |
| 174 | SignalBarsChanged(this, count); |
| 175 | } |
| 176 |
| 177 | void VoIPControllerWrapper::SetConfig(VoIPConfig^ wrapper){ |
| 178 | VoIPController::Config config{0}; |
| 179 | config.initTimeout=wrapper->initTimeout; |
| 180 | config.recvTimeout=wrapper->recvTimeout; |
| 181 | config.dataSaving=(int)wrapper->dataSaving; |
| 182 | config.logFilePath; |
| 183 | config.statsDumpFilePath; |
| 184 |
| 185 | config.enableAEC=wrapper->enableAEC; |
| 186 | config.enableNS=wrapper->enableNS; |
| 187 | config.enableAGC=wrapper->enableAGC; |
| 188 |
| 189 | config.enableCallUpgrade=wrapper->enableCallUpgrade; |
| 190 |
| 191 | config.logPacketStats=wrapper->logPacketStats; |
| 192 | config.enableVolumeControl=wrapper->enableVolumeControl; |
| 193 |
| 194 | config.enableVideoSend=wrapper->enableVideoSend; |
| 195 | config.enableVideoReceive=wrapper->enableVideoReceive; |
| 196 |
| 197 | if(wrapper->logFilePath!=nullptr&&!wrapper->logFilePath->IsEmpty()){ |
| 198 | config.logFilePath = wstring(wrapper->logFilePath->Data()); |
| 199 | } |
| 200 | if (wrapper->statsDumpFilePath != nullptr&&!wrapper->statsDumpFilePath->IsEmpty()){ |
| 201 | config.statsDumpFilePath = wstring(wrapper->statsDumpFilePath->Data()); |
| 202 | } |
| 203 |
| 204 | controller->SetConfig(config); |
| 205 | } |
| 206 |
| 207 | void VoIPControllerWrapper::SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password){ |
| 208 | char _address[2000]; |
| 209 | char _username[256]; |
| 210 | char _password[256]; |
| 211 |
| 212 | WideCharToMultiByte(CP_UTF8, 0, address->Data(), -1, _address, sizeof(_address), NULL, NULL); |
| 213 | WideCharToMultiByte(CP_UTF8, 0, username->Data(), -1, _username, sizeof(_username), NULL, NULL); |
| 214 | WideCharToMultiByte(CP_UTF8, 0, password->Data(), -1, _password, sizeof(_password), NULL, NULL); |
| 215 |
| 216 | controller->SetProxy((int)protocol, _address, port, _username, _password); |
| 217 | } |
| 218 |
| 219 | void VoIPControllerWrapper::SetAudioOutputGainControlEnabled(bool enabled){ |
| 220 | controller->SetAudioOutputGainControlEnabled(enabled); |
| 221 | } |
| 222 |
| 223 | void VoIPControllerWrapper::SetInputVolume(float level){ |
| 224 | controller->SetInputVolume(level); |
| 225 | } |
| 226 |
| 227 | void VoIPControllerWrapper::SetOutputVolume(float level){ |
| 228 | controller->SetOutputVolume(level); |
| 229 | } |
| 230 |
| 231 | void VoIPControllerWrapper::UpdateServerConfig(Platform::String^ json){ |
| 232 | std::string config=ToUtf8(json->Data(), json->Length()); |
| 233 | ServerConfig::GetSharedInstance()->Update(config); |
| 234 | } |
| 235 |
| 236 | void VoIPControllerWrapper::SwitchSpeaker(bool external){ |
| 237 | auto routingManager = AudioRoutingManager::GetDefault(); |
| 238 | if (external){ |
| 239 | routingManager->SetAudioEndpoint(AudioRoutingEndpoint::Speakerphone); |
| 240 | } |
| 241 | else{ |
| 242 | if ((routingManager->AvailableAudioEndpoints & AvailableAudioRoutingEndpoints::Bluetooth) == AvailableAudioRoutingEndpoints::Bluetooth){ |
| 243 | routingManager->SetAudioEndpoint(AudioRoutingEndpoint::Bluetooth); |
| 244 | } |
| 245 | else if ((routingManager->AvailableAudioEndpoints & AvailableAudioRoutingEndpoints::Earpiece) == AvailableAudioRoutingEndpoints::Earpiece){ |
| 246 | routingManager->SetAudioEndpoint(AudioRoutingEndpoint::Earpiece); |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 |
| 251 | void MicrosoftCryptoImpl::AesIgeEncrypt(uint8_t* in, uint8_t* out, size_t len, uint8_t* key, uint8_t* iv){ |
| 252 | IBuffer^ keybuf=IBufferFromPtr(key, 32); |
| 253 | CryptographicKey^ _key=aesKeyProvider->CreateSymmetricKey(keybuf); |
| 254 | uint8_t tmpOut[16]; |
| 255 | uint8_t* xPrev=iv+16; |
| 256 | uint8_t* yPrev=iv; |
| 257 | uint8_t x[16]; |
| 258 | uint8_t y[16]; |
| 259 | for(size_t offset=0;offset<len;offset+=16){ |
| 260 | for (size_t i=0;i<16;i++){ |
| 261 | if (offset+i < len){ |
| 262 | x[i] = in[offset+i]; |
| 263 | } |
| 264 | else{ |
| 265 | x[i]=0; |
| 266 | } |
| 267 | } |
| 268 | XorInt128(x, yPrev, y); |
| 269 | IBuffer^ inbuf=IBufferFromPtr(y, 16); |
| 270 | IBuffer^ outbuf=CryptographicEngine::Encrypt(_key, inbuf, nullptr); |
| 271 | IBufferToPtr(outbuf, 16, tmpOut); |
| 272 | XorInt128(tmpOut, xPrev, y); |
| 273 | memcpy(xPrev, x, 16); |
| 274 | memcpy(yPrev, y, 16); |
| 275 | memcpy(out+offset, y, 16); |
| 276 | } |
| 277 | } |
| 278 |
| 279 | void MicrosoftCryptoImpl::AesIgeDecrypt(uint8_t* in, uint8_t* out, size_t len, uint8_t* key, uint8_t* iv){ |
| 280 | IBuffer^ keybuf=IBufferFromPtr(key, 32); |
| 281 | CryptographicKey^ _key=aesKeyProvider->CreateSymmetricKey(keybuf); |
| 282 | uint8_t tmpOut[16]; |
| 283 | uint8_t* xPrev=iv; |
| 284 | uint8_t* yPrev=iv+16; |
| 285 | uint8_t x[16]; |
| 286 | uint8_t y[16]; |
| 287 | for(size_t offset=0;offset<len;offset+=16){ |
| 288 | for (size_t i=0;i<16;i++){ |
| 289 | if (offset+i < len){ |
| 290 | x[i] = in[offset+i]; |
| 291 | } |
| 292 | else{ |
| 293 | x[i]=0; |
| 294 | } |
| 295 | } |
| 296 | XorInt128(x, yPrev, y); |
| 297 | IBuffer^ inbuf=IBufferFromPtr(y, 16); |
| 298 | IBuffer^ outbuf=CryptographicEngine::Decrypt(_key, inbuf, nullptr); |
| 299 | IBufferToPtr(outbuf, 16, tmpOut); |
| 300 | XorInt128(tmpOut, xPrev, y); |
| 301 | memcpy(xPrev, x, 16); |
| 302 | memcpy(yPrev, y, 16); |
| 303 | memcpy(out+offset, y, 16); |
| 304 | } |
| 305 | } |
| 306 |
| 307 | #define GETU32(pt) (((uint32_t)(pt)[0] << 24) ^ ((uint32_t)(pt)[1] << 16) ^ ((uint32_t)(pt)[2] << 8) ^ ((uint32_t)(pt)[3])) |
| 308 | #define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } |
| 309 |
| 310 | typedef uint8_t u8; |
| 311 |
| 312 | #define L_ENDIAN |
| 313 |
| 314 | /* increment counter (128-bit int) by 2^64 */ |
| 315 | static void AES_ctr128_inc(unsigned char *counter) { |
| 316 | unsigned long c; |
| 317 |
| 318 | /* Grab 3rd dword of counter and increment */ |
| 319 | #ifdef L_ENDIAN |
| 320 | c = GETU32(counter + 8); |
| 321 | c++; |
| 322 | PUTU32(counter + 8, c); |
| 323 | #else |
| 324 | c = GETU32(counter + 4); |
| 325 | c++; |
| 326 | PUTU32(counter + 4, c); |
| 327 | #endif |
| 328 |
| 329 | /* if no overflow, we're done */ |
| 330 | if (c) |
| 331 | return; |
| 332 |
| 333 | /* Grab top dword of counter and increment */ |
| 334 | #ifdef L_ENDIAN |
| 335 | c = GETU32(counter + 12); |
| 336 | c++; |
| 337 | PUTU32(counter + 12, c); |
| 338 | #else |
| 339 | c = GETU32(counter + 0); |
| 340 | c++; |
| 341 | PUTU32(counter + 0, c); |
| 342 | #endif |
| 343 |
| 344 | } |
| 345 |
| 346 | void MicrosoftCryptoImpl::AesCtrEncrypt(uint8_t* inout, size_t len, uint8_t* key, uint8_t* counter, uint8_t* ecount_buf, uint32_t* num){ |
| 347 | unsigned int n; |
| 348 | unsigned long l = len; |
| 349 |
| 350 | //assert(in && out && key && counter && num); |
| 351 | //assert(*num < AES_BLOCK_SIZE); |
| 352 |
| 353 | IBuffer^ keybuf = IBufferFromPtr(key, 32); |
| 354 | CryptographicKey^ _key = aesKeyProvider->CreateSymmetricKey(keybuf); |
| 355 |
| 356 | n = *num; |
| 357 |
| 358 | while (l--) { |
| 359 | if (n == 0) { |
| 360 | IBuffer^ inbuf = IBufferFromPtr(counter, 16); |
| 361 | IBuffer^ outbuf = CryptographicEngine::Encrypt(_key, inbuf, nullptr); |
| 362 | IBufferToPtr(outbuf, 16, ecount_buf); |
| 363 | //AES_encrypt(counter, ecount_buf, key); |
| 364 | AES_ctr128_inc(counter); |
| 365 | } |
| 366 | *inout = *(inout++) ^ ecount_buf[n]; |
| 367 | n = (n + 1) % 16; |
| 368 | } |
| 369 |
| 370 | *num = n; |
| 371 | } |
| 372 |
| 373 | void MicrosoftCryptoImpl::SHA1(uint8_t* msg, size_t len, uint8_t* out){ |
| 374 | //EnterCriticalSection(&hashMutex); |
| 375 |
| 376 | IBuffer^ arr=IBufferFromPtr(msg, len); |
| 377 | CryptographicHash^ hash=sha1Provider->CreateHash(); |
| 378 | hash->Append(arr); |
| 379 | IBuffer^ res=hash->GetValueAndReset(); |
| 380 | IBufferToPtr(res, 20, out); |
| 381 |
| 382 | //LeaveCriticalSection(&hashMutex); |
| 383 | } |
| 384 |
| 385 | void MicrosoftCryptoImpl::SHA256(uint8_t* msg, size_t len, uint8_t* out){ |
| 386 | //EnterCriticalSection(&hashMutex); |
| 387 |
| 388 | IBuffer^ arr=IBufferFromPtr(msg, len); |
| 389 | CryptographicHash^ hash=sha256Provider->CreateHash(); |
| 390 | hash->Append(arr); |
| 391 | IBuffer^ res=hash->GetValueAndReset(); |
| 392 | IBufferToPtr(res, 32, out); |
| 393 | //LeaveCriticalSection(&hashMutex); |
| 394 | } |
| 395 |
| 396 | void MicrosoftCryptoImpl::RandBytes(uint8_t* buffer, size_t len){ |
| 397 | IBuffer^ res=CryptographicBuffer::GenerateRandom(len); |
| 398 | IBufferToPtr(res, len, buffer); |
| 399 | } |
| 400 |
| 401 | void MicrosoftCryptoImpl::Init(){ |
| 402 | /*sha1Hash=HashAlgorithmProvider::OpenAlgorithm(HashAlgorithmNames::Sha1)->CreateHash(); |
| 403 | sha256Hash=HashAlgorithmProvider::OpenAlgorithm(HashAlgorithmNames::Sha256)->CreateHash();*/ |
| 404 | sha1Provider=HashAlgorithmProvider::OpenAlgorithm(HashAlgorithmNames::Sha1); |
| 405 | sha256Provider=HashAlgorithmProvider::OpenAlgorithm(HashAlgorithmNames::Sha256); |
| 406 | aesKeyProvider=SymmetricKeyAlgorithmProvider::OpenAlgorithm(SymmetricAlgorithmNames::AesEcb); |
| 407 | } |
| 408 |
| 409 | void MicrosoftCryptoImpl::XorInt128(uint8_t* a, uint8_t* b, uint8_t* out){ |
| 410 | uint64_t* _a=reinterpret_cast<uint64_t*>(a); |
| 411 | uint64_t* _b=reinterpret_cast<uint64_t*>(b); |
| 412 | uint64_t* _out=reinterpret_cast<uint64_t*>(out); |
| 413 | _out[0]=_a[0]^_b[0]; |
| 414 | _out[1]=_a[1]^_b[1]; |
| 415 | } |
| 416 |
| 417 | void MicrosoftCryptoImpl::IBufferToPtr(IBuffer^ buffer, size_t len, uint8_t* out) |
| 418 | { |
| 419 | ComPtr<IBufferByteAccess> bufferByteAccess; |
| 420 | reinterpret_cast<IInspectable*>(buffer)->QueryInterface(IID_PPV_ARGS(&bufferByteAccess)); |
| 421 |
| 422 | byte* hashBuffer; |
| 423 | bufferByteAccess->Buffer(&hashBuffer); |
| 424 | CopyMemory(out, hashBuffer, len); |
| 425 | } |
| 426 |
| 427 | IBuffer^ MicrosoftCryptoImpl::IBufferFromPtr(uint8_t* msg, size_t len) |
| 428 | { |
| 429 | ComPtr<NativeBuffer> nativeBuffer=Make<NativeBuffer>((byte *)msg, len); |
| 430 | return reinterpret_cast<IBuffer^>(nativeBuffer.Get()); |
| 431 | } |
| 432 |
| 433 | /*Platform::String^ VoIPControllerWrapper::TestAesIge(){ |
| 434 | MicrosoftCryptoImpl::Init(); |
| 435 | Platform::String^ res=""; |
| 436 | Platform::Array<uint8>^ data=ref new Platform::Array<uint8>(32); |
| 437 | Platform::Array<uint8>^ out=ref new Platform::Array<uint8>(32); |
| 438 | Platform::Array<uint8>^ key=ref new Platform::Array<uint8>(16); |
| 439 | Platform::Array<uint8>^ iv=ref new Platform::Array<uint8>(32); |
| 440 |
| 441 |
| 442 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("0000000000000000000000000000000000000000000000000000000000000000"), &data); |
| 443 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"), &iv); |
| 444 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("000102030405060708090a0b0c0d0e0f"), &key); |
| 445 | MicrosoftCryptoImpl::AesIgeEncrypt(data->Data, out->Data, 32, key->Data, iv->Data); |
| 446 | res+=CryptographicBuffer::EncodeToHexString(CryptographicBuffer::CreateFromByteArray(out)); |
| 447 | res+="\n"; |
| 448 |
| 449 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("1A8519A6557BE652E9DA8E43DA4EF4453CF456B4CA488AA383C79C98B34797CB"), &data); |
| 450 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"), &iv); |
| 451 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("000102030405060708090a0b0c0d0e0f"), &key); |
| 452 | MicrosoftCryptoImpl::AesIgeDecrypt(data->Data, out->Data, 32, key->Data, iv->Data); |
| 453 | res+=CryptographicBuffer::EncodeToHexString(CryptographicBuffer::CreateFromByteArray(out)); |
| 454 | res+="\n"; |
| 455 |
| 456 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("99706487A1CDE613BC6DE0B6F24B1C7AA448C8B9C3403E3467A8CAD89340F53B"), &data); |
| 457 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("6D656E746174696F6E206F6620494745206D6F646520666F72204F70656E5353"), &iv); |
| 458 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("5468697320697320616E20696D706C65"), &key); |
| 459 | MicrosoftCryptoImpl::AesIgeEncrypt(data->Data, out->Data, 32, key->Data, iv->Data); |
| 460 | res+=CryptographicBuffer::EncodeToHexString(CryptographicBuffer::CreateFromByteArray(out)); |
| 461 | res+="\n"; |
| 462 |
| 463 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("4C2E204C6574277320686F70652042656E20676F74206974207269676874210A"), &data); |
| 464 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("6D656E746174696F6E206F6620494745206D6F646520666F72204F70656E5353"), &iv); |
| 465 | CryptographicBuffer::CopyToByteArray(CryptographicBuffer::DecodeFromHexString("5468697320697320616E20696D706C65"), &key); |
| 466 | MicrosoftCryptoImpl::AesIgeDecrypt(data->Data, out->Data, 32, key->Data, iv->Data); |
| 467 | res+=CryptographicBuffer::EncodeToHexString(CryptographicBuffer::CreateFromByteArray(out)); |
| 468 | return res; |
| 469 | }*/ |