{"action":"created","issue":{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/57","labels_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/57/comments","events_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/57/events","html_url":"https://github.com/krzyzanowskim/CryptoSwift/issues/57","id":71608568,"number":57,"title":"AES decryption with PKCS7 padding seems to read last byte incorrectly","user":{"login":"gyamana","id":10286008,"avatar_url":"https://avatars.githubusercontent.com/u/10286008?v=3","gravatar_id":"","url":"https://api.github.com/users/gyamana","html_url":"https://github.com/gyamana","followers_url":"https://api.github.com/users/gyamana/followers","following_url":"https://api.github.com/users/gyamana/following{/other_user}","gists_url":"https://api.github.com/users/gyamana/gists{/gist_id}","starred_url":"https://api.github.com/users/gyamana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyamana/subscriptions","organizations_url":"https://api.github.com/users/gyamana/orgs","repos_url":"https://api.github.com/users/gyamana/repos","events_url":"https://api.github.com/users/gyamana/events{/privacy}","received_events_url":"https://api.github.com/users/gyamana/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-28T14:40:10Z","updated_at":"2015-04-29T07:32:21Z","closed_at":null,"body":"Hello,\r\n\r\nA newbie iOS developer here, but please hear me out.\r\n\r\nI have been scratching my head over the last couple of hours around trailing characters after decryption.\r\n\r\nI am using CryptoSwift 0.0.10, and it seems that the PKCS7.remove() function is removing one byte of padding only, despite the bytes value being larger than 1.\r\n\r\nThe following is the byte array before padding removal:\r\n\r\n    [84, 104, 105, 115, 32, 105, 115, 32, 109, 121, 32, 111, 114, 105, 103, 105, 110, 97, 108, 32, 116, 101, 120, 116, 8, 8, 8, 8, 8, 8, 8, 8]\r\n\r\nThe following is the output I see after padding removal has been executed:\r\n\r\n    This is my original text\b\b\b\b\b\b\b\r\n\r\nAs you can see, there are 7 special characters trailing the decrypted text (the characters show up as 'backspace', which corresponds to U+0008) \r\n\r\nI have managed to work out that I can actually change the CryptoSwift's code under the Pods directory and recompile to see the results.\r\n\r\nInitially I put in a series of println statements to grab the above.\r\n\r\nThe code seems to be correct, and it actually works if I cut and paste the first line like so:\r\n\r\n    var padding = Int(bytes.last!) // last byte\r\n    padding = Int(bytes.last!) // last byte\r\n\r\nHowever without re-initializing the padding variable, it remains as a value of 1 no matter what the value of the last byte is.\r\n\r\nWould you be able to look at whether this is an issue, or a misuse of the library?\r\n\r\nRegards,\r\n\r\nGeorge\r\n"},"comment":{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/comments/97331776","html_url":"https://github.com/krzyzanowskim/CryptoSwift/issues/57#issuecomment-97331776","issue_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/57","id":97331776,"user":{"login":"krzyzanowskim","id":758033,"avatar_url":"https://avatars.githubusercontent.com/u/758033?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyzanowskim","html_url":"https://github.com/krzyzanowskim","followers_url":"https://api.github.com/users/krzyzanowskim/followers","following_url":"https://api.github.com/users/krzyzanowskim/following{/other_user}","gists_url":"https://api.github.com/users/krzyzanowskim/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyzanowskim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyzanowskim/subscriptions","organizations_url":"https://api.github.com/users/krzyzanowskim/orgs","repos_url":"https://api.github.com/users/krzyzanowskim/repos","events_url":"https://api.github.com/users/krzyzanowskim/events{/privacy}","received_events_url":"https://api.github.com/users/krzyzanowskim/received_events","type":"User","site_admin":false},"created_at":"2015-04-29T07:32:21Z","updated_at":"2015-04-29T07:32:21Z","body":"Can you please setup sample project to reproduce the issue?"}}