Giter Club home page Giter Club logo

open-crypto's Introduction

โš ๏ธ This library has been deprecated in favor of https://github.com/apple/swift-crypto


CryptoKit

API Docs Team Chat MIT License Continuous Integration Swift 5


OpenCrypto is a drop-in replacement for Apple's CryptoKit built on OpenSSL.

This package is meant for use on platforms where CryptoKit is not available, like Linux. Most features from CryptoKit are available, but some are still missing:

  • โœ… MD5
  • โœ… SHA1
  • โœ… SHA2 (256, 384, 512)
  • โœ… HMAC
  • โœ… AES GCM (128, 192, 256)
  • โœ… ChaChaPoly (1305)
  • โŒ Curve25519
  • โŒ NIST P (256, 384, 521)

open-crypto's People

Contributors

alirp88 avatar bmhatfield avatar bre7 avatar brettrtoomey avatar c0deh4cker avatar franzbusch avatar grundoon avatar jdmcd avatar joannis avatar johnbona avatar jseibert avatar loganwright avatar mrmage avatar tanner0101 avatar technikyle avatar vzsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

open-crypto's Issues

crashes in Crypto

Hello guys.
I have this issue when either logging in, or doing any other request. I'm really sorry for not having any more info. I generated the log as well with command script import lldb.macosx.crashlog save_crashlog /tmp/crash.log cont but the crash.log comes empty. can't even attach it because of that
Screenshot 2019-10-02 15 04 16

Steps to reproduce

No consistent steps

Expected behavior

Doesn't crash

Actual behavior

It crashes in Crypto library

Environment

  • Vapor Framework version: Can't find out. I get Error: GeneralError(message: "Unable to locate vapor dependency")
  • Vapor Toolbox version: 3.1.10
  • OS version: Mac OS 10.14.6

BCrypt Regression

screen shot 2018-04-07 at 5 21 12 pm

Using the BCrypt static methods. (possibly the Digest also) takes over 20+ seconds to complete in routes.
  let data = try BCrypt.make(message: "something")
            
  let seasonedPassword = String(bytes: data, encoding: .utf8)!

Using Crypto 3.0
macOS 10.13.3
Xcode 9.3

AES GCM mode requires special handling

GCM is a mode for authenticated encryption and decryption, which needs different input/output (ciphertext + auth tag) and special handling, unlike the other modes.

In its current state, the the .gcm method is useless, decryption will never succeed without the tag โ€“ which is currently lost during encryption.


I can think of a few options to resolve this:

  1. Remove .gcm as a supported mode completely.
    (Simple, but barbaric.)

  2. Add a new interface for authenticated cyphers where the input/output is a tuple of (ciphertext, tag), and move GCM there, implementing the flow as described at the link above.
    (Supporting Additional Auth Data might become possible too.)

  3. The auth tag could be appended to the ciphertext on encryption, and could be split from there for decryption. OpenSSL's default tag size is well known (12 16 bytes). This should be documented, obviously.
    (This implies that the public interface would not change, and this crypto module could communicate with itself.)


Also, CipherTests is a little lacking on the mode coverage, and really needs some tending.

Default AES mode should not be ECB

Vapor defaults to using AES in ECB mode (see https://github.com/vapor/crypto/blob/346ae2b2ea65a4b6f4985a8e8cb25cf61da549d8/Sources/Crypto/Cipher/Cipher.swift#L13). This has the advantage of not having to choose an initialization vector, but it is problematic in the case where plaintexts are repetitive or can be chosen by the attacker (see https://crypto.stackexchange.com/questions/20941/why-shouldnt-i-use-ecb-encryption for an explanation).

I'd suggest deprecating the currently declared encryption-mode constants in favor of new ones that use CBC, CFB or GCM mode. This makes it necessary to choose an IV, which could automatically be done at random (similar to how we generate a new salt for each Bcrypt hash). (Note that the chosen IV does need to be stored (unencrypted) alongside the ciphertext.)

generate RSA keys

I want to generate rsa-4096 key and encrypt data using tag, oaep padding and sha1 digest. How can i do this?

Issue when signing JWT

Link to a repo with issue

Basically compile. Run. And hit the GET http://localhost:8080/user/me

and it should throw something like this.

screen shot 2018-07-19 at 23 43 33

Keys

-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAra8h4Q9+bkbuOyS47CeM62dvuoph/daO9VaKmYYqV+htLXv2
QmwkGWbaMtHMBg5uUVWMYniLBsmqQ9l6h8XuVYVP7b8mOtSAXCYDRnfIo5r0HrzH
G91I9X25xtaWYZdQH0MjQPxGroP8lMKgv8uCQPhJGjbYZ7v641v51uFdmqRkOZNx
1+6LhW0ViIdR/EwnOcfiiz3kF71Hadorgr7GX7iLOYEkgsjXhxs1+tVK+vuUFNwi
Uvp0rH8CFvqCcFa6OR5fIG9A9UlZeh4ki1dEVvdZsAjATXj3GY7HiWV5zKHQpsDY
13uKTY6s9fSjBMiig3qXFPWl8SFCpzU/3f7UVcTLsoAo1Di7aHB3iiR4xGB5nlUK
X2iHEfnXYJYWodc5PAyc0yLtO4dQX2TYTdcCzuThd+/os7RWz8p2Tuw1XX68jtMi
Bv4WHHWvQaTN54uWWr3oAWOpAvPYqkHZpG4oY3dU2Z55dr+XE2QzWY1ivEzCJ7Kc
MmMcHKY2mtGP+R7W1hc6Iv49A3L4R/5kFwhhA5OLDYB72ZRAema6QxXPAHpc/6ZG
lq4mh72zkL494LpozuNjIAixjYdz9og5TLB53ZWKMfiUmhhMCDFqPIsAhRhG55oG
wkgio99dKd7fdvRSY4uQltM72VSb/9C2Dzvphg9L+9gOKaXpj1Twk9ot0dsCAwEA
AQKCAgAM7XIqHEsezizBPjR9b1wv0V0hl1c/2458eFqMns3cCTLHJejofMAbG+q1
yaPT95MCfsmaMrq2YKBJuJBENtlMiEWwvn+L9XEwaqvnvNa0Rr5Q42A2lLvvedIw
GJzM2sRd71NabOyd5Lk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sOg8LYQ8yM1pULXQahgO
e/0Ly7u/xHFqDyTtz4qquve2OEJXmzNNyBl9geROTQr/yap9HRHIgHTdTjr4U1Jf
zVLsPyZzlgieE2t9Ghu8sOhNt+qg5eya9DaxC7F7g2Nu3ZIldva+HxQbHLqU
-----END RSA PRIVATE KEY-----



-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAra8h4Q9+bkbuOyS47CeM
62dvuoph/daO9VaKmYYqV+htLXv2QmwkGWbaMtHMBg5uUVWMYniLBsmqQ9l6h8Xu
VYVP7b8mOtSAXCYDRnfIo5r0HrzHG91I9X25xtaWYZdQH0MjQPxGroP8lMKgv8uC
QPhJGjbYZ7v641v51uFdmqRkOZNx1+6LhW0ViIdR/EwnOcfiiz3kF71Hadorgr7G
X7iLOYEkgsjXhxs1+tVK+vuUFNwiUvp0rH8CFvqCcFa6OR5fIG9A9UlZeh4ki1dE
VvdZsAjATXj3GY7HiWV5zKHQpsDY13uKTY6s9fSjBMiig3qXFPWl8SFCpzU/3f7U
VcTLsoAo1Di7aHB3iiR4xGB5nlUKX2iHEfnXYJYWodc5PAyc0yLtO4dQX2TYTdcC
zuThd+/os7RWz8p2Tuw1XX68jtMiBv4WHHWvQaTN54uWWr3oAWOpAvPYqkHZpG4o
Y3dU2Z55dr+XE2QzWY1ivEzCJ7KcMmMcHKY2mtGP+R7W1hc6Iv49A3L4R/5kFwhh
A5OLDYB72ZRAema6QxXPAHpc/6ZGlq4mh72zkL494LpozuNjIAixjYdz9og5TLB5
3ZWKMfiUmhhMCDFqPIsAhRhG55oGwkgio99dKd7fdvRSY4uQltM72VSb/9C2Dzvp
hg9L+9gOKaXpj1Twk9ot0dsCAwEAAQ==
-----END PUBLIC KEY-----

Reproducible Crash When Encrypting/Decrypting RSA

This simple code crashes (segfault).

import Crypto

let passphrase = "abcdef"

// From https://www.googleapis.com/oauth2/v3/certs
let key = try RSAKey.components(n: "vvAaaSpfr934Qx0ioFiWsopq7UCfLNn0zjYVbq4bvUcGSXU9kowYmQArR7WlIkjk1moffla0UV75QRaQPATva1oD5xQnnW-20haeMWTSsMgUHoN0Np9AD8ffPz-DfMJBOHIo4REL1BFFS33HSZgPl0hxJ-5UScqr4lW1JMy5XGeRho30dnmKTpakU1Oc35hFYKSea_O2SXfmbqiAkWlWkilEzgHq4pzVWiDZe4ZgfMdD4vqkSNrO_PkBFBT1mnBJztQ1h4v1jvUW-zeYYwIcPTaOX-xOTiGH9uQkcNPpe5pBrIZJqR5VNrDl_bJOmvVlhhXZSn4fkxA8kyQcZXGaTw", e: "AQAB")
let encryptedPassphrase = try RSA.encrypt(passphrase, padding: .pkcs1, key: key)
try print(RSA.decrypt(encryptedPassphrase, padding: .pkcs1, key: key))

Reproducing 100% with version 3.3.0 (5605334) of Crypto. Tested of macOS 10.14.2, with Xcode 10.1, and the standard Swift version for this Xcode version, and on Debian, with Swift 4.2.1.

Crash when reading invalid/malformed key string

Hi,

I'm reading a key from string stored in DB, but if the key is malformed, the following code crashes the app without throwing any error.

let rsaKey = try RSAKey.public(pem: key)
let signer = JWTSigner.rs512(key: rsaKey)
_ = try JWT<JWTIdentity>(from: identityHeader, verifiedUsing: signer)

Specifically the fault line is:

let rsaKey = try RSAKey.public(pem: key)

Error message:

Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

rsaKey error

If the key is well formed the error is not throwed...
Any idea?

SHA256 hash is wrong for newlines

When you try to hash a string which contains newlines
example:
test\ntest

the hash is different than the hash of this string (tried on different online hashing tools):
test test
But since String does not support newlines in any other way than \n or \r\n or \r you are not able to produce the correct hash. This is important for Amazon AWS access because exactly that has is needed there.

Could the IV be automatically extracted from the encrypted data?

More like a question.

So this works fine:

let data = "The black knight always triumphs!".convertToData()
let key = "01234567890123456789012345678901".convertToData()
let iv = try CryptoRandom().generateData(count: 16)
let encryptedData = try AES256CBC.encrypt(data, key: key, iv: iv)

let decryptedData = try AES256CBC.decrypt(encryptedData, key: key, iv: iv)
print(decryptedData.convert(to: String.self)) // The black knight always triumphs!

Question is can I not pass in the iv as argument so it could be automatically extracted from the encrypted data? As in:

let decryptedData = try AES256CBC.decrypt(encryptedData, key: key) <<--
print(decryptedData.convert(to: String.self))

Throws: โš ๏ธ [CryptoError.cipherIVSize: Invalid cipher IV length 0 != 16.]

I'm trying to avoid having to pass the IV around as in here (relies on Apple's CommonCryto / CCCryptor).

Thanks.

Using with iOS

I'm guessing there is no way to include this in an iOS project? I'm using Vapor on my backend and it would be really convenient to use the same library for encrypting at the server and decrypting at the client side.

Error: AES256GCM.encrypt: expression type 'Data' is ambiguous without more context

Hello,
I am having a problem right now and don't know how to solve it.
I wrote a controller for managing my users. The following code is an excerpt from my registration function, where a key is generated for encrypting user data that is later stored in the database. The key (ekey) is stored in the database, too. So I need to enctrypt the key and therefore I use a hash of the users password.
I'm getting the error on the last line, but I don't know what is wrong with that.

// generate key for encrypting data
let ekey = try URandom().generateData(count: 32).base64EncodedString()
 
// generate digest for password and encrypt 'ekey'
let key: Data = try SHA256.hash(user.password)
let iv: Data = try URandom().generateData(count: 12)
let (encrKey, tag) = try AES256GCM.encrypt(ekey, key: key, iv: iv)

Add PKCS#7/Cryptographic Message Syntax Support

Iโ€™d love to see support for PKCS#7/Cryptographic Message Syntax (CMS) added to Vapor Crypto. It would allow me to, for example, sign or encrypt iOS configuration profiles (https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/profile-service/profile-service.html#//apple_ref/doc/uid/TP40009505-CH2-SW37). At the very least I can replace a HUGE amount of my Java EE code base with server-side Swift.

Add private/public key parsing for using with RSA

A convenience parser to make a pub/priv keyhole digestible by RSA alg.

Essentially transforming this
"-----BEGIN PRIVATE KEY-----\nQklCTElPR1JBUEhZ==\n-----END PRIVATE KEY-----\n"

Into this
QklCTElPR1JBUEhZ

Then base64 decoded into this
BIBLIOGRAPHY

Crash when decrypting base64 encoded secret

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: CryptoKit.CryptoError(identifier: "EVP_CipherFinal_ex", reason: "Failed finishing cipher.: error:00000000:lib(0):func(0):reason(0).")
This is my library to encrypt/decrypt passwords for remote nodes on my CI:
https://github.com/Einstore/Speedster/blob/master/Sources/SpeedsterApi/Libs/Secrets.swift
the tests for it here:
https://github.com/Einstore/Speedster/blob/master/Tests/SpeedsterApiTests/SecretsTests.swift

It only crashes if the secret has been decoded from base64 string ...

Should we archive this repo when we migrate to Swift Crypto?

Since the plan is to migrate Vapor's Crypto reliance to Swift Crypto should this repo be archived to mark the fact that it is no longer maintained. We could potentially lose a couple of helpful wrappers that are common crypto operations and not currently supported by Swift Crypto - namely RSA key support and PEM/DER key support. Anyone wanting these features may need to vend their own copy of BoringSSL whereas we could write a library to support it, until such a time as Swift Crypto adds supports (see apple/swift-crypto#26 and apple/swift-crypto#27)

Bcrypt verifyPassword not working

Trying to use bcrypt to hash passwords, but when I verifyPassword it never returns true.

Steps to reproduce:

let password = "test123456"
let hash = try BCrypt.hashPassword(password)
let verify = try BCrypt.verifyPassword(password, matchesHash: hash)
print(verify) //false

OpenSSL 1.1 compatibility

Update Crypto to be OpenSSL 1.1 compatible.

Ubuntu 18.04 ships with OpenSSL 1.1 as part the standard install. However, since Crypto is not yet OpenSSL 1.1 compatible, then Vapor on a source level would not be Ubuntu 18.04 compatible. [see vapor/documentation/issues/359 comments]

Although an OpenSSL 1.1-compatible Crypto may not happen any time soon due current priorities and/or level of effort required, this issue provides a place to (1) communicate this as a known issue and (2) provide some guidance or milestone as to how far out a Vapor/Crypto with OpenSSL 1.1 might be.

Conform DigestAlgorithm to Equatable

DigestAlgorithm does not conform to Equatable at the moment. It would useful for cases when you wanted to have different implementations of a method based on the algorithm used.

Currently, to check equality of the DigestAlgorithm, you need to do something like the following:

switch Int(algorithm.type) {
case Int(DigestAlgorithm.sha256.type): // Using SHA256...
default: // Do something here...
}

Implementation of the required methods would be very simple. Something like this would work:

return Int(lhs.type) == Int(rhs.type)

That might be more verbose the needed.

Heap Buffer Overflow with AES Encryption

Getting a heap buffer overflow runtime crash when trying to encrypt "large" amounts of data. On my 16GB MBPr, the magic number is anything over 1536 bytes for it to crash. When I change out the encryption implementation to an OpenSSL-based one (using IBM-Swift/BlueCryptor on Linux - not Mac since it'll sub it for CommonCrypto), it successfully encrypts the data with seemingly no limit on size. The implementation of cbc128.c for both LibreSSL and OpenSSL is identical.

Sample main.swift:

import Cipher
import Random

let key = "passwordpasswordpasswordpassword".bytes
let iv = "passwordpassword".bytes
let plainText = URandom.bytes(1537)

let encryptedText = try Cipher(.aes256(.cbc), key: key, iv: iv).encrypt(plainText).base64String

Crash output using Address Sanitizer:

AddressSanitizer debugger support is active. Memory error breakpoint has been installed and you can now use the 'memory history' command.
=================================================================
==2334==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6190000072a0 at pc 0x000100f9a7fd bp 0x7fff5fbfdc80 sp 0x7fff5fbfdc78
WRITE of size 8 at 0x6190000072a0 thread T0
    #0 0x100f9a7fc in CRYPTO_cbc128_encrypt cbc128.c:91
    #1 0x100fe78b7 in aes_cbc_cipher e_aes.c:584
    #2 0x10101fdd9 in EVP_EncryptUpdate evp_enc.c:359
    #3 0x1014f09e8 in @nonobjc EVP_EncryptUpdate(UnsafeMutablePointer<evp_cipher_ctx_st>!, UnsafeMutablePointer<UInt8>!, UnsafeMutablePointer<Int32>!, UnsafePointer<UInt8>!, Int32) -> Int32 Cipher.swift
    #4 0x1014f0a08 in thunk Cipher.swift
    #5 0x1014f0b65 in partial apply for thunk Cipher.swift
    #6 0x1014efb3d in Cipher.libreCipher(stream : ByteStream, initialize : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafePointer<evp_cipher_st>, UnsafePointer<UInt8>, UnsafePointer<UInt8>?) -> Int32, update : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>, UnsafePointer<UInt8>, Int32) -> Int32, final : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>) -> Int32) throws -> [UInt8] Cipher.swift:111
    #7 0x1014eaf7d in Cipher.encrypt(ByteStream) throws -> [UInt8] Cipher.swift:60
    #8 0x1014f1bc7 in Cipher.encrypt([UInt8]) throws -> [UInt8] Cipher.swift:136
    #9 0x1000022c8 in main main.swift:83
    #10 0x7fff9e0c0254 in start (libdyld.dylib+0x5254)

0x6190000072a0 is located 0 bytes to the right of 1056-byte region [0x619000006e80,0x6190000072a0)
allocated by thread T0 here:
    #0 0x100107c60 in wrap_malloc (libclang_rt.asan_osx_dynamic.dylib+0x4ac60)
    #1 0x102e14958 in swift_slowAlloc (libswiftCore.dylib+0x21a958)
    #2 0x1014ef05a in Cipher.libreCipher(stream : ByteStream, initialize : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafePointer<evp_cipher_st>, UnsafePointer<UInt8>, UnsafePointer<UInt8>?) -> Int32, update : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>, UnsafePointer<UInt8>, Int32) -> Int32, final : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>) -> Int32) throws -> [UInt8] Cipher.swift:102
    #3 0x1014eaf7d in Cipher.encrypt(ByteStream) throws -> [UInt8] Cipher.swift:60
    #4 0x1014f1bc7 in Cipher.encrypt([UInt8]) throws -> [UInt8] Cipher.swift:136
    #5 0x1000022c8 in main main.swift:83
    #6 0x7fff9e0c0254 in start (libdyld.dylib+0x5254)

SUMMARY: AddressSanitizer: heap-buffer-overflow cbc128.c:91 in CRYPTO_cbc128_encrypt
Shadow bytes around the buggy address:
  0x1c3200000e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3200000e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3200000e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3200000e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3200000e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1c3200000e50: 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa
  0x1c3200000e60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3200000e70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3200000e80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3200000e90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3200000ea0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
2016-10-17 10:44:07.451185 App[2334:221509] =================================================================
2016-10-17 10:44:07.452415 App[2334:221509] ==2334==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6190000072a0 at pc 0x000100f9a7fd bp 0x7fff5fbfdc80 sp 0x7fff5fbfdc78
2016-10-17 10:44:07.452458 App[2334:221509] WRITE of size 8 at 0x6190000072a0 thread T0
2016-10-17 10:44:07.452483 App[2334:221509]     #0 0x100f9a7fc in CRYPTO_cbc128_encrypt cbc128.c:91
2016-10-17 10:44:07.452518 App[2334:221509]     #1 0x100fe78b7 in aes_cbc_cipher e_aes.c:584
2016-10-17 10:44:07.452540 App[2334:221509]     #2 0x10101fdd9 in EVP_EncryptUpdate evp_enc.c:359
2016-10-17 10:44:07.452560 App[2334:221509]     #3 0x1014f09e8 in @nonobjc EVP_EncryptUpdate(UnsafeMutablePointer<evp_cipher_ctx_st>!, UnsafeMutablePointer<UInt8>!, UnsafeMutablePointer<Int32>!, UnsafePointer<UInt8>!, Int32) -> Int32 Cipher.swift
2016-10-17 10:44:07.452624 App[2334:221509]     #4 0x1014f0a08 in thunk Cipher.swift
2016-10-17 10:44:07.452709 App[2334:221509]     #5 0x1014f0b65 in partial apply for thunk Cipher.swift
2016-10-17 10:44:07.452741 App[2334:221509]     #6 0x1014efb3d in Cipher.libreCipher(stream : ByteStream, initialize : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafePointer<evp_cipher_st>, UnsafePointer<UInt8>, UnsafePointer<UInt8>?) -> Int32, update : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>, UnsafePointer<UInt8>, Int32) -> Int32, final : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>) -> Int32) throws -> [UInt8] Cipher.swift:111
2016-10-17 10:44:07.452760 App[2334:221509]     #7 0x1014eaf7d in Cipher.encrypt(ByteStream) throws -> [UInt8] Cipher.swift:60
2016-10-17 10:44:07.452782 App[2334:221509]     #8 0x1014f1bc7 in Cipher.encrypt([UInt8]) throws -> [UInt8] Cipher.swift:136
2016-10-17 10:44:07.452807 App[2334:221509]     #9 0x1000022c8 in main main.swift:83
2016-10-17 10:44:07.452824 App[2334:221509]     #10 0x7fff9e0c0254 in start (libdyld.dylib+0x5254)
2016-10-17 10:44:07.452836 App[2334:221509] 
2016-10-17 10:44:07.452851 App[2334:221509] 0x6190000072a0 is located 0 bytes to the right of 1056-byte region [0x619000006e80,0x6190000072a0)
2016-10-17 10:44:07.452866 App[2334:221509] allocated by thread T0 here:
2016-10-17 10:44:07.452875 App[2334:221509]     #0 0x100107c60 in wrap_malloc (libclang_rt.asan_osx_dynamic.dylib+0x4ac60)
2016-10-17 10:44:07.452884 App[2334:221509]     #1 0x102e14958 in swift_slowAlloc (libswiftCore.dylib+0x21a958)
2016-10-17 10:44:07.452896 App[2334:221509]     #2 0x1014ef05a in Cipher.libreCipher(stream : ByteStream, initialize : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafePointer<evp_cipher_st>, UnsafePointer<UInt8>, UnsafePointer<UInt8>?) -> Int32, update : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>, UnsafePointer<UInt8>, Int32) -> Int32, final : (UnsafeMutablePointer<evp_cipher_ctx_st>, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<Int32>) -> Int32) throws -> [UInt8] Cipher.swift:102
2016-10-17 10:44:07.453105 App[2334:221509]     #3 0x1014eaf7d in Cipher.encrypt(ByteStream) throws -> [UInt8] Cipher.swift:60
2016-10-17 10:44:07.453148 App[2334:221509]     #4 0x1014f1bc7 in Cipher.encrypt([UInt8]) throws -> [UInt8] Cipher.swift:136
2016-10-17 10:44:07.453176 App[2334:221509]     #5 0x1000022c8 in main main.swift:83
2016-10-17 10:44:07.453187 App[2334:221509]     #6 0x7fff9e0c0254 in start (libdyld.dylib+0x5254)
2016-10-17 10:44:07.453195 App[2334:221509] 
2016-10-17 10:44:07.453205 App[2334:221509] SUMMARY: AddressSanitizer: heap-buffer-overflow cbc128.c:91 in CRYPTO_cbc128_encrypt
2016-10-17 10:44:07.453214 App[2334:221509] Shadow bytes around the buggy address:
2016-10-17 10:44:07.453272 App[2334:221509]   0x1c3200000e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2016-10-17 10:44:07.453349 App[2334:221509]   0x1c3200000e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2016-10-17 10:44:07.453363 App[2334:221509]   0x1c3200000e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2016-10-17 10:44:07.453396 App[2334:221509]   0x1c3200000e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2016-10-17 10:44:07.453430 App[2334:221509]   0x1c3200000e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2016-10-17 10:44:07.453452 App[2334:221509] =>0x1c3200000e50: 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa
2016-10-17 10:44:07.453463 App[2334:221509]   0x1c3200000e60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
2016-10-17 10:44:07.453472 App[2334:221509]   0x1c3200000e70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
2016-10-17 10:44:07.453481 App[2334:221509]   0x1c3200000e80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
2016-10-17 10:44:07.453490 App[2334:221509]   0x1c3200000e90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
2016-10-17 10:44:07.453507 App[2334:221509]   0x1c3200000ea0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
2016-10-17 10:44:07.453524 App[2334:221509] Shadow byte legend (one shadow byte represents 8 application bytes):
2016-10-17 10:44:07.453639 App[2334:221509]   Addressable:           00
2016-10-17 10:44:07.453657 App[2334:221509]   Partially addressable: 01 02 03 04 05 06 07
2016-10-17 10:44:07.453666 App[2334:221509]   Heap left redzone:       fa
2016-10-17 10:44:07.453675 App[2334:221509]   Heap right redzone:      fb
2016-10-17 10:44:07.453702 App[2334:221509]   Freed heap region:       fd
2016-10-17 10:44:07.453732 App[2334:221509]   Stack left redzone:      f1
2016-10-17 10:44:07.453749 App[2334:221509]   Stack mid redzone:       f2
2016-10-17 10:44:07.453758 App[2334:221509]   Stack right redzone:     f3
2016-10-17 10:44:07.453767 App[2334:221509]   Stack partial redzone:   f4
2016-10-17 10:44:07.453775 App[2334:221509]   Stack after return:      f5
2016-10-17 10:44:07.453783 App[2334:221509]   Stack use after scope:   f8
2016-10-17 10:44:07.453792 App[2334:221509]   Global redzone:          f9
2016-10-17 10:44:07.453800 App[2334:221509]   Global init order:       f6
2016-10-17 10:44:07.453808 App[2334:221509]   Poisoned by user:        f7
2016-10-17 10:44:07.453822 App[2334:221509]   Container overflow:      fc
2016-10-17 10:44:07.453937 App[2334:221509]   Array cookie:            ac
2016-10-17 10:44:07.453954 App[2334:221509]   Intra object redzone:    bb
2016-10-17 10:44:07.453963 App[2334:221509]   ASan internal:           fe
2016-10-17 10:44:07.453971 App[2334:221509]   Left alloca redzone:     ca
2016-10-17 10:44:07.453979 App[2334:221509]   Right alloca redzone:    cb
2016-10-17 10:44:07.454013 App[2334:221509] 
==2334==ABORTING
AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
Program ended with exit code: 9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.