whisper.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. // Copyright 2016 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package whisperv5
  17. import (
  18. "bytes"
  19. "crypto/ecdsa"
  20. crand "crypto/rand"
  21. "crypto/sha256"
  22. "fmt"
  23. "runtime"
  24. "sync"
  25. "time"
  26. "github.com/ethereum/go-ethereum/common"
  27. "github.com/ethereum/go-ethereum/crypto"
  28. "github.com/ethereum/go-ethereum/logger"
  29. "github.com/ethereum/go-ethereum/logger/glog"
  30. "github.com/ethereum/go-ethereum/p2p"
  31. "github.com/ethereum/go-ethereum/rpc"
  32. "golang.org/x/crypto/pbkdf2"
  33. set "gopkg.in/fatih/set.v0"
  34. )
  35. // Whisper represents a dark communication interface through the Ethereum
  36. // network, using its very own P2P communication layer.
  37. type Whisper struct {
  38. protocol p2p.Protocol
  39. filters *Filters
  40. privateKeys map[string]*ecdsa.PrivateKey
  41. symKeys map[string][]byte
  42. keyMu sync.RWMutex
  43. envelopes map[common.Hash]*Envelope // Pool of envelopes currently tracked by this node
  44. messages map[common.Hash]*ReceivedMessage // Pool of successfully decrypted messages, which are not expired yet
  45. expirations map[uint32]*set.SetNonTS // Message expiration pool
  46. poolMu sync.RWMutex // Mutex to sync the message and expiration pools
  47. peers map[*Peer]struct{} // Set of currently active peers
  48. peerMu sync.RWMutex // Mutex to sync the active peer set
  49. mailServer MailServer
  50. messageQueue chan *Envelope
  51. p2pMsgQueue chan *Envelope
  52. quit chan struct{}
  53. overflow bool
  54. test bool
  55. }
  56. // New creates a Whisper client ready to communicate through the Ethereum P2P network.
  57. // Param s should be passed if you want to implement mail server, otherwise nil.
  58. func New() *Whisper {
  59. whisper := &Whisper{
  60. privateKeys: make(map[string]*ecdsa.PrivateKey),
  61. symKeys: make(map[string][]byte),
  62. envelopes: make(map[common.Hash]*Envelope),
  63. messages: make(map[common.Hash]*ReceivedMessage),
  64. expirations: make(map[uint32]*set.SetNonTS),
  65. peers: make(map[*Peer]struct{}),
  66. messageQueue: make(chan *Envelope, messageQueueLimit),
  67. p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
  68. quit: make(chan struct{}),
  69. }
  70. whisper.filters = NewFilters(whisper)
  71. // p2p whisper sub protocol handler
  72. whisper.protocol = p2p.Protocol{
  73. Name: ProtocolName,
  74. Version: uint(ProtocolVersion),
  75. Length: NumberOfMessageCodes,
  76. Run: whisper.HandlePeer,
  77. }
  78. return whisper
  79. }
  80. // APIs returns the RPC descriptors the Whisper implementation offers
  81. func (w *Whisper) APIs() []rpc.API {
  82. return []rpc.API{
  83. {
  84. Namespace: ProtocolName,
  85. Version: ProtocolVersionStr,
  86. Service: NewPublicWhisperAPI(w),
  87. Public: true,
  88. },
  89. }
  90. }
  91. func (w *Whisper) RegisterServer(server MailServer) {
  92. w.mailServer = server
  93. }
  94. // Protocols returns the whisper sub-protocols ran by this particular client.
  95. func (w *Whisper) Protocols() []p2p.Protocol {
  96. return []p2p.Protocol{w.protocol}
  97. }
  98. // Version returns the whisper sub-protocols version number.
  99. func (w *Whisper) Version() uint {
  100. return w.protocol.Version
  101. }
  102. func (w *Whisper) getPeer(peerID []byte) (*Peer, error) {
  103. w.peerMu.Lock()
  104. defer w.peerMu.Unlock()
  105. for p := range w.peers {
  106. id := p.peer.ID()
  107. if bytes.Equal(peerID, id[:]) {
  108. return p, nil
  109. }
  110. }
  111. return nil, fmt.Errorf("Could not find peer with ID: %x", peerID)
  112. }
  113. // MarkPeerTrusted marks specific peer trusted, which will allow it
  114. // to send historic (expired) messages.
  115. func (w *Whisper) MarkPeerTrusted(peerID []byte) error {
  116. p, err := w.getPeer(peerID)
  117. if err != nil {
  118. return err
  119. }
  120. p.trusted = true
  121. return nil
  122. }
  123. func (w *Whisper) RequestHistoricMessages(peerID []byte, envelope *Envelope) error {
  124. p, err := w.getPeer(peerID)
  125. if err != nil {
  126. return err
  127. }
  128. p.trusted = true
  129. return p2p.Send(p.ws, p2pRequestCode, envelope)
  130. }
  131. func (w *Whisper) SendP2PMessage(peerID []byte, envelope *Envelope) error {
  132. p, err := w.getPeer(peerID)
  133. if err != nil {
  134. return err
  135. }
  136. return p2p.Send(p.ws, p2pCode, envelope)
  137. }
  138. func (w *Whisper) SendP2PDirect(peer *Peer, envelope *Envelope) error {
  139. return p2p.Send(peer.ws, p2pCode, envelope)
  140. }
  141. // NewIdentity generates a new cryptographic identity for the client, and injects
  142. // it into the known identities for message decryption.
  143. func (w *Whisper) NewIdentity() *ecdsa.PrivateKey {
  144. key, err := crypto.GenerateKey()
  145. if err != nil || !validatePrivateKey(key) {
  146. key, err = crypto.GenerateKey() // retry once
  147. }
  148. if err != nil {
  149. panic(err)
  150. }
  151. if !validatePrivateKey(key) {
  152. panic("Failed to generate valid key")
  153. }
  154. w.keyMu.Lock()
  155. defer w.keyMu.Unlock()
  156. w.privateKeys[common.ToHex(crypto.FromECDSAPub(&key.PublicKey))] = key
  157. return key
  158. }
  159. // DeleteIdentity deletes the specified key if it exists.
  160. func (w *Whisper) DeleteIdentity(key string) {
  161. w.keyMu.Lock()
  162. defer w.keyMu.Unlock()
  163. delete(w.privateKeys, key)
  164. }
  165. // HasIdentity checks if the the whisper node is configured with the private key
  166. // of the specified public pair.
  167. func (w *Whisper) HasIdentity(pubKey string) bool {
  168. w.keyMu.RLock()
  169. defer w.keyMu.RUnlock()
  170. return w.privateKeys[pubKey] != nil
  171. }
  172. // GetIdentity retrieves the private key of the specified public identity.
  173. func (w *Whisper) GetIdentity(pubKey string) *ecdsa.PrivateKey {
  174. w.keyMu.RLock()
  175. defer w.keyMu.RUnlock()
  176. return w.privateKeys[pubKey]
  177. }
  178. func (w *Whisper) GenerateSymKey(name string) error {
  179. const size = aesKeyLength * 2
  180. buf := make([]byte, size)
  181. _, err := crand.Read(buf)
  182. if err != nil {
  183. return err
  184. } else if !validateSymmetricKey(buf) {
  185. return fmt.Errorf("error in GenerateSymKey: crypto/rand failed to generate random data")
  186. }
  187. key := buf[:aesKeyLength]
  188. salt := buf[aesKeyLength:]
  189. derived, err := DeriveOneTimeKey(key, salt, EnvelopeVersion)
  190. if err != nil {
  191. return err
  192. } else if !validateSymmetricKey(derived) {
  193. return fmt.Errorf("failed to derive valid key")
  194. }
  195. w.keyMu.Lock()
  196. defer w.keyMu.Unlock()
  197. if w.symKeys[name] != nil {
  198. return fmt.Errorf("Key with name [%s] already exists", name)
  199. }
  200. w.symKeys[name] = derived
  201. return nil
  202. }
  203. func (w *Whisper) AddSymKey(name string, key []byte) error {
  204. if w.HasSymKey(name) {
  205. return fmt.Errorf("Key with name [%s] already exists", name)
  206. }
  207. derived, err := deriveKeyMaterial(key, EnvelopeVersion)
  208. if err != nil {
  209. return err
  210. }
  211. w.keyMu.Lock()
  212. defer w.keyMu.Unlock()
  213. // double check is necessary, because deriveKeyMaterial() is slow
  214. if w.symKeys[name] != nil {
  215. return fmt.Errorf("Key with name [%s] already exists", name)
  216. }
  217. w.symKeys[name] = derived
  218. return nil
  219. }
  220. func (w *Whisper) HasSymKey(name string) bool {
  221. w.keyMu.RLock()
  222. defer w.keyMu.RUnlock()
  223. return w.symKeys[name] != nil
  224. }
  225. func (w *Whisper) DeleteSymKey(name string) {
  226. w.keyMu.Lock()
  227. defer w.keyMu.Unlock()
  228. delete(w.symKeys, name)
  229. }
  230. func (w *Whisper) GetSymKey(name string) []byte {
  231. w.keyMu.RLock()
  232. defer w.keyMu.RUnlock()
  233. return w.symKeys[name]
  234. }
  235. // Watch installs a new message handler to run in case a matching packet arrives
  236. // from the whisper network.
  237. func (w *Whisper) Watch(f *Filter) (string, error) {
  238. return w.filters.Install(f)
  239. }
  240. func (w *Whisper) GetFilter(id string) *Filter {
  241. return w.filters.Get(id)
  242. }
  243. // Unwatch removes an installed message handler.
  244. func (w *Whisper) Unwatch(id string) {
  245. w.filters.Uninstall(id)
  246. }
  247. // Send injects a message into the whisper send queue, to be distributed in the
  248. // network in the coming cycles.
  249. func (w *Whisper) Send(envelope *Envelope) error {
  250. return w.add(envelope)
  251. }
  252. // Start implements node.Service, starting the background data propagation thread
  253. // of the Whisper protocol.
  254. func (w *Whisper) Start(*p2p.Server) error {
  255. glog.V(logger.Info).Infoln("Whisper started")
  256. go w.update()
  257. numCPU := runtime.NumCPU()
  258. for i := 0; i < numCPU; i++ {
  259. go w.processQueue()
  260. }
  261. return nil
  262. }
  263. // Stop implements node.Service, stopping the background data propagation thread
  264. // of the Whisper protocol.
  265. func (w *Whisper) Stop() error {
  266. close(w.quit)
  267. glog.V(logger.Info).Infoln("Whisper stopped")
  268. return nil
  269. }
  270. // handlePeer is called by the underlying P2P layer when the whisper sub-protocol
  271. // connection is negotiated.
  272. func (wh *Whisper) HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
  273. // Create the new peer and start tracking it
  274. whisperPeer := newPeer(wh, peer, rw)
  275. wh.peerMu.Lock()
  276. wh.peers[whisperPeer] = struct{}{}
  277. wh.peerMu.Unlock()
  278. defer func() {
  279. wh.peerMu.Lock()
  280. delete(wh.peers, whisperPeer)
  281. wh.peerMu.Unlock()
  282. }()
  283. // Run the peer handshake and state updates
  284. if err := whisperPeer.handshake(); err != nil {
  285. return err
  286. }
  287. whisperPeer.start()
  288. defer whisperPeer.stop()
  289. return wh.runMessageLoop(whisperPeer, rw)
  290. }
  291. // runMessageLoop reads and processes inbound messages directly to merge into client-global state.
  292. func (wh *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
  293. for {
  294. // fetch the next packet
  295. packet, err := rw.ReadMsg()
  296. if err != nil {
  297. return err
  298. }
  299. switch packet.Code {
  300. case statusCode:
  301. // this should not happen, but no need to panic; just ignore this message.
  302. glog.V(logger.Warn).Infof("%v: unxepected status message received", p.peer)
  303. case messagesCode:
  304. // decode the contained envelopes
  305. var envelopes []*Envelope
  306. if err := packet.Decode(&envelopes); err != nil {
  307. glog.V(logger.Warn).Infof("%v: failed to decode envelope: [%v], peer will be disconnected", p.peer, err)
  308. return fmt.Errorf("garbage received")
  309. }
  310. // inject all envelopes into the internal pool
  311. for _, envelope := range envelopes {
  312. if err := wh.add(envelope); err != nil {
  313. glog.V(logger.Warn).Infof("%v: bad envelope received: [%v], peer will be disconnected", p.peer, err)
  314. return fmt.Errorf("invalid envelope")
  315. }
  316. p.mark(envelope)
  317. }
  318. case p2pCode:
  319. // peer-to-peer message, sent directly to peer bypassing PoW checks, etc.
  320. // this message is not supposed to be forwarded to other peers, and
  321. // therefore might not satisfy the PoW, expiry and other requirements.
  322. // these messages are only accepted from the trusted peer.
  323. if p.trusted {
  324. var envelope Envelope
  325. if err := packet.Decode(&envelope); err != nil {
  326. glog.V(logger.Warn).Infof("%v: failed to decode direct message: [%v], peer will be disconnected", p.peer, err)
  327. return fmt.Errorf("garbage received (directMessage)")
  328. }
  329. wh.postEvent(&envelope, true)
  330. }
  331. case p2pRequestCode:
  332. // Must be processed if mail server is implemented. Otherwise ignore.
  333. if wh.mailServer != nil {
  334. var request Envelope
  335. if err := packet.Decode(&request); err != nil {
  336. glog.V(logger.Warn).Infof("%v: failed to decode p2p request message: [%v], peer will be disconnected", p.peer, err)
  337. return fmt.Errorf("garbage received (p2p request)")
  338. }
  339. wh.mailServer.DeliverMail(p, &request)
  340. }
  341. default:
  342. // New message types might be implemented in the future versions of Whisper.
  343. // For forward compatibility, just ignore.
  344. }
  345. packet.Discard()
  346. }
  347. }
  348. // add inserts a new envelope into the message pool to be distributed within the
  349. // whisper network. It also inserts the envelope into the expiration pool at the
  350. // appropriate time-stamp. In case of error, connection should be dropped.
  351. func (wh *Whisper) add(envelope *Envelope) error {
  352. now := uint32(time.Now().Unix())
  353. sent := envelope.Expiry - envelope.TTL
  354. if sent > now {
  355. if sent-SynchAllowance > now {
  356. return fmt.Errorf("envelope created in the future [%x]", envelope.Hash())
  357. } else {
  358. // recalculate PoW, adjusted for the time difference, plus one second for latency
  359. envelope.calculatePoW(sent - now + 1)
  360. }
  361. }
  362. if envelope.Expiry < now {
  363. if envelope.Expiry+SynchAllowance*2 < now {
  364. return fmt.Errorf("very old message")
  365. } else {
  366. glog.V(logger.Debug).Infof("expired envelope dropped [%x]", envelope.Hash())
  367. return nil // drop envelope without error
  368. }
  369. }
  370. if len(envelope.Data) > MaxMessageLength {
  371. return fmt.Errorf("huge messages are not allowed [%x]", envelope.Hash())
  372. }
  373. if len(envelope.Version) > 4 {
  374. return fmt.Errorf("oversized version [%x]", envelope.Hash())
  375. }
  376. if len(envelope.AESNonce) > AESNonceMaxLength {
  377. // the standard AES GSM nonce size is 12,
  378. // but const gcmStandardNonceSize cannot be accessed directly
  379. return fmt.Errorf("oversized AESNonce [%x]", envelope.Hash())
  380. }
  381. if len(envelope.Salt) > saltLength {
  382. return fmt.Errorf("oversized salt [%x]", envelope.Hash())
  383. }
  384. if envelope.PoW() < MinimumPoW && !wh.test {
  385. glog.V(logger.Debug).Infof("envelope with low PoW dropped: %f [%x]", envelope.PoW(), envelope.Hash())
  386. return nil // drop envelope without error
  387. }
  388. hash := envelope.Hash()
  389. wh.poolMu.Lock()
  390. _, alreadyCached := wh.envelopes[hash]
  391. if !alreadyCached {
  392. wh.envelopes[hash] = envelope
  393. if wh.expirations[envelope.Expiry] == nil {
  394. wh.expirations[envelope.Expiry] = set.NewNonTS()
  395. }
  396. if !wh.expirations[envelope.Expiry].Has(hash) {
  397. wh.expirations[envelope.Expiry].Add(hash)
  398. }
  399. }
  400. wh.poolMu.Unlock()
  401. if alreadyCached {
  402. glog.V(logger.Detail).Infof("whisper envelope already cached [%x]\n", envelope.Hash())
  403. } else {
  404. glog.V(logger.Detail).Infof("cached whisper envelope [%x]: %v\n", envelope.Hash(), envelope)
  405. wh.postEvent(envelope, false) // notify the local node about the new message
  406. if wh.mailServer != nil {
  407. wh.mailServer.Archive(envelope)
  408. }
  409. }
  410. return nil
  411. }
  412. // postEvent queues the message for further processing.
  413. func (w *Whisper) postEvent(envelope *Envelope, isP2P bool) {
  414. // if the version of incoming message is higher than
  415. // currently supported version, we can not decrypt it,
  416. // and therefore just ignore this message
  417. if envelope.Ver() <= EnvelopeVersion {
  418. if isP2P {
  419. w.p2pMsgQueue <- envelope
  420. } else {
  421. w.checkOverflow()
  422. w.messageQueue <- envelope
  423. }
  424. }
  425. }
  426. // checkOverflow checks if message queue overflow occurs and reports it if necessary.
  427. func (w *Whisper) checkOverflow() {
  428. queueSize := len(w.messageQueue)
  429. if queueSize == messageQueueLimit {
  430. if !w.overflow {
  431. w.overflow = true
  432. glog.V(logger.Warn).Infoln("message queue overflow")
  433. }
  434. } else if queueSize <= messageQueueLimit/2 {
  435. if w.overflow {
  436. w.overflow = false
  437. }
  438. }
  439. }
  440. // processQueue delivers the messages to the watchers during the lifetime of the whisper node.
  441. func (w *Whisper) processQueue() {
  442. var e *Envelope
  443. for {
  444. select {
  445. case <-w.quit:
  446. return
  447. case e = <-w.messageQueue:
  448. w.filters.NotifyWatchers(e, false)
  449. case e = <-w.p2pMsgQueue:
  450. w.filters.NotifyWatchers(e, true)
  451. }
  452. }
  453. }
  454. // update loops until the lifetime of the whisper node, updating its internal
  455. // state by expiring stale messages from the pool.
  456. func (w *Whisper) update() {
  457. // Start a ticker to check for expirations
  458. expire := time.NewTicker(expirationCycle)
  459. // Repeat updates until termination is requested
  460. for {
  461. select {
  462. case <-expire.C:
  463. w.expire()
  464. case <-w.quit:
  465. return
  466. }
  467. }
  468. }
  469. // expire iterates over all the expiration timestamps, removing all stale
  470. // messages from the pools.
  471. func (w *Whisper) expire() {
  472. w.poolMu.Lock()
  473. defer w.poolMu.Unlock()
  474. now := uint32(time.Now().Unix())
  475. for then, hashSet := range w.expirations {
  476. // Short circuit if a future time
  477. if then > now {
  478. continue
  479. }
  480. // Dump all expired messages and remove timestamp
  481. hashSet.Each(func(v interface{}) bool {
  482. delete(w.envelopes, v.(common.Hash))
  483. delete(w.messages, v.(common.Hash))
  484. return true
  485. })
  486. w.expirations[then].Clear()
  487. }
  488. }
  489. // envelopes retrieves all the messages currently pooled by the node.
  490. func (w *Whisper) Envelopes() []*Envelope {
  491. w.poolMu.RLock()
  492. defer w.poolMu.RUnlock()
  493. all := make([]*Envelope, 0, len(w.envelopes))
  494. for _, envelope := range w.envelopes {
  495. all = append(all, envelope)
  496. }
  497. return all
  498. }
  499. // Messages retrieves all the decrypted messages matching a filter id.
  500. func (w *Whisper) Messages(id string) []*ReceivedMessage {
  501. result := make([]*ReceivedMessage, 0)
  502. w.poolMu.RLock()
  503. defer w.poolMu.RUnlock()
  504. if filter := w.filters.Get(id); filter != nil {
  505. for _, msg := range w.messages {
  506. if filter.MatchMessage(msg) {
  507. result = append(result, msg)
  508. }
  509. }
  510. }
  511. return result
  512. }
  513. func (w *Whisper) addDecryptedMessage(msg *ReceivedMessage) {
  514. w.poolMu.Lock()
  515. defer w.poolMu.Unlock()
  516. w.messages[msg.EnvelopeHash] = msg
  517. }
  518. func ValidatePublicKey(k *ecdsa.PublicKey) bool {
  519. return k != nil && k.X != nil && k.Y != nil && k.X.Sign() != 0 && k.Y.Sign() != 0
  520. }
  521. func validatePrivateKey(k *ecdsa.PrivateKey) bool {
  522. if k == nil || k.D == nil || k.D.Sign() == 0 {
  523. return false
  524. }
  525. return ValidatePublicKey(&k.PublicKey)
  526. }
  527. // validateSymmetricKey returns false if the key contains all zeros
  528. func validateSymmetricKey(k []byte) bool {
  529. return len(k) > 0 && !containsOnlyZeros(k)
  530. }
  531. func containsOnlyZeros(data []byte) bool {
  532. for _, b := range data {
  533. if b != 0 {
  534. return false
  535. }
  536. }
  537. return true
  538. }
  539. func bytesToIntLittleEndian(b []byte) (res uint64) {
  540. mul := uint64(1)
  541. for i := 0; i < len(b); i++ {
  542. res += uint64(b[i]) * mul
  543. mul *= 256
  544. }
  545. return res
  546. }
  547. func BytesToIntBigEndian(b []byte) (res uint64) {
  548. for i := 0; i < len(b); i++ {
  549. res *= 256
  550. res += uint64(b[i])
  551. }
  552. return res
  553. }
  554. // DeriveSymmetricKey derives symmetric key material from the key or password.
  555. // pbkdf2 is used for security, in case people use password instead of randomly generated keys.
  556. func deriveKeyMaterial(key []byte, version uint64) (derivedKey []byte, err error) {
  557. if version == 0 {
  558. // kdf should run no less than 0.1 seconds on average compute,
  559. // because it's a once in a session experience
  560. derivedKey := pbkdf2.Key(key, nil, 65356, aesKeyLength, sha256.New)
  561. return derivedKey, nil
  562. } else {
  563. return nil, unknownVersionError(version)
  564. }
  565. }