Skip to content

Instantly share code, notes, and snippets.

@v2ray
Last active July 25, 2016 20:11
Show Gist options
  • Save v2ray/9f767596bbd671d441b9a3f41c2e1128 to your computer and use it in GitHub Desktop.
Save v2ray/9f767596bbd671d441b9a3f41c2e1128 to your computer and use it in GitHub Desktop.
[101 233 173 59 19 86 15 72 110 12 222 34 211 154 52 124 162 74 47 152 93 27 213 207 48 7 2 75 155 245 102 191 61 206 45 158 246 99 44 158 194 93 63 166 19 119 137 39 86 211 3 243 31 192 131 228 251 50 200 239 5 248 223 255 130 221 168 149 198 243 126 177 199 17 247 146 81 76 93 1 132 27 29 206 4 30 136 81 151 39 222 205 60 146 72 10 127 196 201 49 122 199 58 226 132 171 103 15 33 70 25 49 183 48 71 115 237 196 118 143 158 41 254 79 240 220 140 189]
[148 150 240 113 64 124 195 253 94 203 76 226 209 219 40 65 53 45 75 207 238 250 186 25 202 80 198 78 215 109 185 211 86 134 66 228 61 8 83 107 24 204 186 142 157 67 171 127 189 246 171 147 180 226 60 184 82 189 46 154 230 117 207 138 18 73 207 38 254 122 221 254 20 55 90 119 227 76 154 165 144 125 20 161 110 243 163 49 163 136 76 156 170 201 235 135 46 32 35 99 128 49 72 248 253 139 31 237 188 198 229 31 67 168 40 35 80 205 28 84 252 191 174 72 58 40 135 4]
[101 233 173 59 19 86 15 72 110 12 222 34 211 154 52 124 162 74 47 152 93 27 213 207 48 7 2 75 155 245 102 191 61 206 45 158 246 99 44 158 194 93 63 166 19 119 137 39 86 211 3 243 31 192 131 228 251 50 200 239 5 248 223 255 130 221 168 149 198 243 126 177 199 17 247 146 81 76 93 1 132 27 29 206 4 30 136 81 151 39 222 205 60 146 72 10 127 196 201 49 122 199 58 226 132 171 103 15 33 70 25 49 183 48 71 115 237 196 118 143 158 41 254 79 240 220 140 189]
[231 52 5 174 213 165 113 249 169 29 41 176 130 214 105 125 38 81 50 86 89 5 93 158 167 32 220 134 167 103 46 181 66 10 228 175 140 164 22 124 70 246 88 169 50 49 144 22 225 227 68 128 242 4 245 107 101 27 54 160 245 36 83 66 115 162 245 223 149 217 178 4 247 214 101 82 83 13 65 60 19 124 121 153 183 255 231 135 109 112 26 200 112 10 151 102 20 140 166 75 177 172 69 23 94 58 226 39 175 114 59 105 92 21 239 19 70 230 201 211 55 166 24 58 19 81 156 200]
true
false
package main
import (
"bytes"
"fmt"
"github.com/aead/chacha20"
"github.com/v2ray/v2ray-core/common/crypto"
)
func main() {
key := []byte("12345678901234567890123456789012")
iv := []byte("123456789012")
//input := []byte("12345678901234567890123456789012345678901234567890123456789012345")
input := make([]byte, 128)
c1 := crypto.NewChaCha20Stream(key, iv)
output1 := make([]byte, len(input))
oo1 := make([]byte, len(input))
c1.XORKeyStream(output1, input)
fmt.Println(output1)
c1.XORKeyStream(oo1, output1)
fmt.Println(oo1)
var key32 [32]byte
var iv12 [12]byte
copy(key32[:], key)
copy(iv12[:], iv)
c2 := chacha20.NewCipher(&iv12, &key32)
output2 := make([]byte, len(input))
c2.XORKeyStream(output2, input)
fmt.Println(output2)
oo2 := make([]byte, len(input))
c2.XORKeyStream(oo2, output2)
fmt.Println(oo2)
fmt.Println(bytes.Equal(output1, output2))
fmt.Println(bytes.Equal(oo1, oo2))
}
@aead
Copy link

aead commented Jul 25, 2016

Okay, can reproduce it and it only affects amd64 - Probably bug in the setState asm...

@aead
Copy link

aead commented Jul 25, 2016

Yes, a bug, thank you for report 👍
Line 325 - 326 a missing PADDQ X15, X3

@aead
Copy link

aead commented Jul 25, 2016

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment